add auth jdbc and server code

This commit is contained in:
XuYi 2017-05-10 18:11:50 +08:00
parent 22a454e424
commit 301085374b
79 changed files with 32293 additions and 0 deletions

15
pom.xml
View File

@ -14,6 +14,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<hadoop.version>2.6.0</hadoop.version>
<jline.version>2.14.1</jline.version>
<derby.version>10.12.1.1</derby.version>
</properties>
<dependencies>
@ -37,6 +39,19 @@
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>${derby.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,31 @@
package cn.edu.thu.tsfiledb.auth;
import cn.edu.thu.tsfiledb.auth.dao.Authorizer;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.model.User;
public class TestAu {
public static void main(String[] args) {
// TODO Auto-generated method stub
// 启动server的时候需要open db
DBdao dBdao = new DBdao();
dBdao.open();
System.out.println("start server.....");
// 操作数据库信息
User user = new User("test", "test");
try {
Authorizer.createUser(user.getUserName(), user.getPassWord());
Authorizer.deleteUser(user.getUserName());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// 关闭server的时候需要 close db
System.out.println("close the server...");
dBdao.close();
}
}

View File

@ -0,0 +1,285 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.RolePermission;
import cn.edu.thu.tsfiledb.auth.model.User;
import cn.edu.thu.tsfiledb.auth.model.UserPermission;
import cn.edu.thu.tsfiledb.auth.model.UserRoleRel;
/**
* @author liukun
*
*/
public class AuthDao {
/**
* if the user don't exist in the db, return true else return false
*
* @param statement
* @param user
* @return
*/
public boolean addUser(Statement statement, User user) {
UserDao dao = new UserDao();
boolean state = false;
// Check the user exist or not
if (dao.getUser(statement, user.getUserName()) == null) {
dao.createUser(statement, user);
state = true;
}
return state;
}
/**
* if the role isn't exist in the db, will return true else return false
*
* @param statement
* @param role
* @return
*/
public boolean addRole(Statement statement, Role role) {
RoleDao dao = new RoleDao();
boolean state = false;
// check the user exist or not
if (dao.getRole(statement, role.getRoleName()) == null) {
dao.createRole(statement, role);
state = true;
}
return state;
}
/**
* the user and role is exist, the relation is not exist, will return true
* else return false
*
* @param statement
* @param userName
* @param roleName
* @return
*/
public boolean addUserRoleRel(Statement statement, String userName, String roleName) {
UserDao userDao = new UserDao();
RoleDao roleDao = new RoleDao();
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
int userId;
int roleId;
User user = null;
Role role = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null) {
if ((role = roleDao.getRole(statement, roleName)) != null) {
userId = user.getId();
roleId = role.getId();
UserRoleRel userRoleRel = new UserRoleRel(userId, roleId);
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) {
state = true;
userRoleRelDao.createUserRoleRel(statement, userRoleRel);
}
}
}
return state;
}
public boolean addUserPermission(Statement statement, String userName, String nodeName, int permissionId) {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
boolean state = false;
User user = null;
if ((user = userDao.getUser(statement, userName)) != null) {
int userId = user.getId();
UserPermission userPermission = new UserPermission(userId, nodeName, permissionId);
if (userPermissionDao.getUserPermission(statement, userPermission) == null) {
state = true;
userPermissionDao.createUserPermission(statement, userPermission);
}
}
return state;
}
public boolean addRolePermission(Statement statement, String roleName, String nodeName, int permissionId) {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
boolean state = false;
Role role = null;
if ((role = roleDao.getRole(statement, roleName)) != null) {
int roleId = role.getId();
RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId);
if (rolePermissionDao.getRolePermission(statement, rolePermission) == null) {
state = true;
rolePermissionDao.createRolePermission(statement, rolePermission);
}
}
return state;
}
public boolean deleteUser(Statement statement, String userName) {
UserDao userDao = new UserDao();
boolean state = false;
if (userDao.deleteUser(statement, userName) > 0) {
state = true;
}
return state;
}
public boolean deleteRole(Statement statement, String roleName) {
RoleDao roleDao = new RoleDao();
boolean state = false;
if (roleDao.deleteRole(statement, roleName) > 0) {
state = true;
}
return state;
}
public boolean deleteUserRoleRel(Statement statement, String userName, String roleName) {
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
UserDao userDao = new UserDao();
RoleDao roleDao = new RoleDao();
int userId;
int roleId;
User user = null;
Role role = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null
&& (role = roleDao.getRole(statement, roleName)) != null) {
userId = user.getId();
roleId = role.getId();
UserRoleRel userRoleRel = new UserRoleRel(userId, roleId);
if (userRoleRelDao.deleteUserRoleRel(statement, userRoleRel) > 0) {
state = true;
}
}
return state;
}
public boolean deleteUserPermission(Statement statement, String userName, String nodeName, int permissionId) {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
int userId;
User user = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null) {
userId = user.getId();
UserPermission userPermission = new UserPermission(userId, nodeName, permissionId);
if (userPermissionDao.deleteUserPermission(statement, userPermission) > 0) {
state = true;
}
}
return state;
}
public boolean deleteRolePermission(Statement statement, String roleName, String nodeName, int permissionId) {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
Role role = null;
int roleId;
boolean state = false;
if ((role = roleDao.getRole(statement, roleName)) != null) {
roleId = role.getId();
RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId);
if (rolePermissionDao.deleteRolePermission(statement, rolePermission) > 0) {
state = true;
}
}
return state;
}
// 如果username或者nodename不存在怎么办
public List<User> getUsers(Statement statement) {
UserDao userDao = new UserDao();
List<User> users = userDao.getUsers(statement);
return users;
}
public List<Role> getRoles(Statement statement) {
RoleDao roleDao = new RoleDao();
List<Role> roles = roleDao.getRoles(statement);
return roles;
}
public List<UserRoleRel> getAllUserRoleRel(Statement statement) {
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
List<UserRoleRel> userRoleRels = userRoleRelDao.getUserRoleRels(statement);
return userRoleRels;
}
/*
* 返回值的问题
*/
public List<Role> getRolesByUser(Statement statement, String userName) {
UserDao userDao = new UserDao();
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
RoleDao roleDao = new RoleDao();
// user不存在的情况下是返回 size = 0还是 null
ArrayList<Role> roles = new ArrayList<>();
User user = userDao.getUser(statement, userName);
if (user != null) {
int userId = user.getId();
List<UserRoleRel> userRoleRels = userRoleRelDao.getUserRoleRelByUser(statement, userId);
for (UserRoleRel userRoleRel : userRoleRels) {
int roleId = userRoleRel.getRoleId();
Role role = roleDao.getRole(statement, roleId);
roles.add(role);
}
}
return roles;
}
/*
* 返回值的问题
*/
public List<UserPermission> getUserPermission(Statement statement, String userName, String nodeName) {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
List<UserPermission> userPermissions = new ArrayList<>();
// 当user 不存在的时候 是返回size = 0还是null
User user = userDao.getUser(statement, userName);
if (user != null) {
userPermissions = userPermissionDao.getUserPermissionByUserAndNodeName(statement, user.getId(), nodeName);
}
// 返回值可能是null还是 没有结果 size = 0
return userPermissions;
}
public List<RolePermission> getRolePermission(Statement statement, String roleName, String nodeName) {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
List<RolePermission> rolePermissions = new ArrayList<>();
Role role = roleDao.getRole(statement, roleName);
if (role != null) {
rolePermissions = rolePermissionDao.getRolePermissionByRoleAndNodeName(statement, role.getId(), nodeName);
}
return rolePermissions;
}
/*
* All user's permission: userPermission and rolePermission
*/
public Set<Integer> getAllUserPermission(Statement statement, String userName, String nodeName) {
// permission set
Set<Integer> permissionSet = new HashSet<>();
// userpermission
List<UserPermission> userPermissions = getUserPermission(statement, userName, nodeName);
for (UserPermission userPermission : userPermissions) {
permissionSet.add(userPermission.getPermissionId());
}
// rolepermission
List<Role> roles = getRolesByUser(statement, userName);
for (Role role : roles) {
List<RolePermission> rolePermissions = getRolePermission(statement, role.getRoleName(), nodeName);
// operation add the permission into the set
for (RolePermission rolePermission : rolePermissions) {
permissionSet.add(rolePermission.getPermissionId());
}
}
return permissionSet;
}
}

View File

@ -0,0 +1,355 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import cn.edu.thu.tsfiledb.auth.model.AuthException;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.RolePermission;
import cn.edu.thu.tsfiledb.auth.model.User;
import cn.edu.thu.tsfiledb.auth.model.UserPermission;
import cn.edu.thu.tsfiledb.auth.model.UserRoleRel;
/**
* @author liukun
*/
public class AuthDaoWrap {
// Must init the DBdao before use this class
private Statement statement = DBdao.getStatement();
public boolean addUser(User user) {
UserDao dao = new UserDao();
boolean state = false;
// Check the user exist or not
if (dao.getUser(statement, user.getUserName()) == null) {
dao.createUser(statement, user);
state = true;
}
return state;
}
public boolean addRole(Role role) {
RoleDao dao = new RoleDao();
boolean state = false;
// check the user exist or not
if (dao.getRole(statement, role.getRoleName()) == null) {
dao.createRole(statement, role);
state = true;
}
return state;
}
public boolean addUserRoleRel(String userName, String roleName) throws AuthException {
UserDao userDao = new UserDao();
RoleDao roleDao = new RoleDao();
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
int userId;
int roleId;
User user = null;
Role role = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null) {
if ((role = roleDao.getRole(statement, roleName)) != null) {
userId = user.getId();
roleId = role.getId();
UserRoleRel userRoleRel = new UserRoleRel(userId, roleId);
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) {
state = true;
userRoleRelDao.createUserRoleRel(statement, userRoleRel);
} else {
throw new AuthException(String.format("The user of %s already has the role of %s", userName, role.getRoleName()));
}
} else {
throw new AuthException("The role is not exist");
}
} else {
throw new AuthException("The user is not exist");
}
return state;
}
public boolean addUserPermission(String userName, String nodeName, int permissionId) throws AuthException {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
boolean state = false;
User user = null;
if ((user = userDao.getUser(statement, userName)) != null) {
int userId = user.getId();
UserPermission userPermission = new UserPermission(userId, nodeName, permissionId);
if (userPermissionDao.getUserPermission(statement, userPermission) == null) {
state = true;
userPermissionDao.createUserPermission(statement, userPermission);
} else {
throw new AuthException("The permission is exist");
}
} else {
throw new AuthException("The user is not exist");
}
return state;
}
public boolean addRolePermission(String roleName, String nodeName, int permissionId) throws AuthException {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
boolean state = false;
Role role = null;
if ((role = roleDao.getRole(statement, roleName)) != null) {
int roleId = role.getId();
RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId);
if (rolePermissionDao.getRolePermission(statement, rolePermission) == null) {
state = true;
rolePermissionDao.createRolePermission(statement, rolePermission);
} else {
throw new AuthException("The permission is exist");
}
} else {
throw new AuthException("The role is not exist");
}
return state;
}
public boolean deleteUser(String userName) {
UserDao userDao = new UserDao();
boolean state = false;
if (userDao.deleteUser(statement, userName) > 0) {
state = true;
}
return state;
}
public boolean deleteRole(String roleName) {
RoleDao roleDao = new RoleDao();
boolean state = false;
if (roleDao.deleteRole(statement, roleName) > 0) {
state = true;
}
return state;
}
public boolean deleteUserRoleRel(String userName, String roleName) throws AuthException {
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
UserDao userDao = new UserDao();
RoleDao roleDao = new RoleDao();
int userId;
int roleId;
User user = null;
Role role = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null) {
if ((role = roleDao.getRole(statement, roleName)) != null) {
userId = user.getId();
roleId = role.getId();
UserRoleRel userRoleRel = new UserRoleRel(userId, roleId);
if (userRoleRelDao.deleteUserRoleRel(statement, userRoleRel) > 0) {
state = true;
} else {
throw new AuthException(String.format("The user of %s does not have the role of %s"), userName, role.getRoleName());
}
} else {
throw new AuthException("The role is not exist");
}
} else {
throw new AuthException("The user is not exist");
}
return state;
}
public boolean deleteUserPermission(String userName, String nodeName, int permissionId) throws AuthException {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
int userId;
User user = null;
boolean state = false;
if ((user = userDao.getUser(statement, userName)) != null) {
userId = user.getId();
UserPermission userPermission = new UserPermission(userId, nodeName, permissionId);
if (userPermissionDao.deleteUserPermission(statement, userPermission) > 0) {
state = true;
} else {
throw new AuthException("The permission is not exist");
}
} else {
throw new AuthException("The user is not exist");
}
return state;
}
public boolean deleteRolePermission(String roleName, String nodeName, int permissionId) throws AuthException {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
Role role = null;
int roleId;
boolean state = false;
if ((role = roleDao.getRole(statement, roleName)) != null) {
roleId = role.getId();
RolePermission rolePermission = new RolePermission(roleId, nodeName, permissionId);
if (rolePermissionDao.deleteRolePermission(statement, rolePermission) > 0) {
state = true;
} else {
throw new AuthException("The permission is not exist");
}
} else {
throw new AuthException("The role is not exist");
}
return state;
}
public User getUser(String userName, String password) {
UserDao userDao = new UserDao();
User user = null;
user = userDao.getUser(statement, userName, password);
return user;
}
public User getUser(String userName) {
UserDao userDao = new UserDao();
User user = null;
user = userDao.getUser(statement, userName);
return user;
}
// 如果username或者nodename不存在怎么办
public List<User> getUsers() {
UserDao userDao = new UserDao();
List<User> users = userDao.getUsers(statement);
return users;
}
public List<Role> getRoles() {
RoleDao roleDao = new RoleDao();
List<Role> roles = roleDao.getRoles(statement);
return roles;
}
public List<UserRoleRel> getAllUserRoleRel() {
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
List<UserRoleRel> userRoleRels = userRoleRelDao.getUserRoleRels(statement);
return userRoleRels;
}
/*
* 返回值的问题
*/
public List<Role> getRolesByUser(String userName) {
UserDao userDao = new UserDao();
UserRoleRelDao userRoleRelDao = new UserRoleRelDao();
RoleDao roleDao = new RoleDao();
// user不存在的情况下是返回 size = 0还是 null
ArrayList<Role> roles = new ArrayList<>();
User user = userDao.getUser(statement, userName);
if (user != null) {
int userId = user.getId();
List<UserRoleRel> userRoleRels = userRoleRelDao.getUserRoleRelByUser(statement, userId);
for (UserRoleRel userRoleRel : userRoleRels) {
int roleId = userRoleRel.getRoleId();
Role role = roleDao.getRole(statement, roleId);
roles.add(role);
}
}
return roles;
}
public UserPermission getUserPermission(String userName, String nodeName, int permissionId) {
UserPermission userPermission = null;
UserDao userDao = new UserDao();
User user = userDao.getUser(statement, userName);
if (user != null) {
int userId = user.getId();
userPermission = new UserPermission(userId, nodeName, permissionId);
UserPermissionDao userPermissionDao = new UserPermissionDao();
// userPermission will be null
userPermission = userPermissionDao.getUserPermission(statement, userPermission);
}
return userPermission;
}
/*
* 返回值的问题
*/
public List<UserPermission> getUserPermissions(String userName, String nodeName) throws AuthException {
UserDao userDao = new UserDao();
UserPermissionDao userPermissionDao = new UserPermissionDao();
List<UserPermission> userPermissions = new ArrayList<>();
// 当user 不存在的时候 是返回size = 0还是null
User user = userDao.getUser(statement, userName);
if (user != null) {
userPermissions = userPermissionDao.getUserPermissionByUserAndNodeName(statement, user.getId(), nodeName);
} else {
throw new AuthException("The user is not exist");
}
// 返回值可能是null还是 没有结果 size = 0
return userPermissions;
}
public List<RolePermission> getRolePermissions(String roleName, String nodeName) {
RoleDao roleDao = new RoleDao();
RolePermissionDao rolePermissionDao = new RolePermissionDao();
List<RolePermission> rolePermissions = new ArrayList<>();
Role role = roleDao.getRole(statement, roleName);
if (role != null) {
rolePermissions = rolePermissionDao.getRolePermissionByRoleAndNodeName(statement, role.getId(), nodeName);
}
return rolePermissions;
}
/*
* All user's permission: userPermission and rolePermission
*/
public Set<Integer> getAllUserPermissions(String userName, String nodeName) throws AuthException {
// permission set
Set<Integer> permissionSet = new HashSet<>();
// userpermission
List<UserPermission> userPermissions = getUserPermissions(userName, nodeName);
for (UserPermission userPermission : userPermissions) {
permissionSet.add(userPermission.getPermissionId());
}
// rolepermission
List<Role> roles = getRolesByUser(userName);
for (Role role : roles) {
List<RolePermission> rolePermissions = getRolePermissions(role.getRoleName(), nodeName);
// operation add the permission into the set
for (RolePermission rolePermission : rolePermissions) {
permissionSet.add(rolePermission.getPermissionId());
}
}
return permissionSet;
}
public boolean updateUserPassword(String userName, String newPassword) {
boolean state = false;
UserDao userDao = new UserDao();
int change = userDao.updateUserPassword(statement, userName, newPassword);
if (change > 0) {
state = true;
}
return state;
}
public boolean checkUserPermission(String userName, String nodeName, int permissionId) {
boolean state = false;
UserPermission userPermission = this.getUserPermission(userName, nodeName, permissionId);
if (userPermission != null) {
state = true;
}
return state;
}
// add the method without the authdao
public boolean checkUser(String userName, String password) {
boolean state = false;
User user = this.getUser(userName, password);
if (user != null) {
state = true;
}
return state;
}
}

View File

@ -0,0 +1,238 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.util.Set;
import cn.edu.thu.tsfiledb.auth.model.AuthException;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.User;
/**
* @author liukun
*/
public class Authorizer {
private static AuthDaoWrap authDaoWrap = new AuthDaoWrap();
/**
* Check the information for login
*
* @param username
* @param password
* @return
* @throws AuthException
*/
public static synchronized boolean login(String username, String password) throws AuthException {
boolean state = false;
state = authDaoWrap.checkUser(username, password);
if (state == false) {
throw new AuthException("The username or the password is not correct");
}
return state;
}
/**
* Add user
*
* @param username is not null or empty
* @param password is not null or empty
* @return true: add user successfully, false: add user unsuccessfully
* @throws AuthException
*/
public static boolean createUser(String username, String password) throws AuthException {
boolean state = false;
User user = new User(username, password);
if (username == null || password == null || "".equals(username) || "".equals(password)) {
throw new AuthException("Username or password can't be empty");
}
state = authDaoWrap.addUser(user);
if (state == false) {
throw new AuthException("The user is exist");
}
return state;
}
/**
* Delete user
*
* @param username
* @return true: delete user successfully, false: delete user unsuccessfully
* @throws AuthException
*/
public static boolean deleteUser(String username) throws AuthException {
boolean state = false;
state = authDaoWrap.deleteUser(username);
if (state == false) {
throw new AuthException("The user is not exist");
}
return state;
}
/**
* Add permission to user
*
* @param username
* @param nodeName
* @param permissionId
* @return true: add permission successfully, false: add permission unsuccessfully
* @throws AuthException
*/
public static boolean addPmsToUser(String username, String nodeName, int permissionId) throws AuthException {
boolean state = false;
state = authDaoWrap.addUserPermission(username, nodeName, permissionId);
return state;
}
/**
* Delete permission from user
*
* @param userName
* @param nodeName
* @param permissionId
* @return true: delete permission from user successfully, false: delete permission from user unsuccessfully
* @throws AuthException
*/
public static boolean removePmsFromUser(String userName, String nodeName, int permissionId) throws AuthException {
boolean state = false;
state = authDaoWrap.deleteUserPermission(userName, nodeName, permissionId);
return state;
}
/**
* Add role
*
* @param roleName
* @return true: add role successfully, false: add role unsuccessfully
* @throws Exception
*/
public static boolean createRole(String roleName) throws AuthException {
boolean state = false;
Role role = new Role(roleName);
state = authDaoWrap.addRole(role);
if (state == false) {
throw new AuthException("The role is exist");
}
return state;
}
/**
* Delete role
*
* @param roleName
* @return true: delete role successfully, false: delete role unsuccessfully
* @throws Exception
*/
public static boolean deleteRole(String roleName) throws AuthException {
boolean state = false;
state = authDaoWrap.deleteRole(roleName);
if (state == false) {
throw new AuthException("The role is not exist");
}
return state;
}
/**
* Add permission to role
*
* @param roleName
* @param nodeName
* @param permissionId
* @return true: add permission to role successfully, false: add permission to role unsuccessfully
* @throws AuthException
*/
public static boolean addPmsToRole(String roleName, String nodeName, int permissionId) throws AuthException {
boolean state = false;
state = authDaoWrap.addRolePermission(roleName, nodeName, permissionId);
return state;
}
/**
* Delete permission from role
*
* @param roleName
* @param nodeName
* @param permissionId
* @return true: delete permission from role successfully, false: delete permission from role unsuccessfully
* @throws AuthException
*/
public static boolean removePmsFromRole(String roleName, String nodeName, int permissionId) throws AuthException {
boolean state = false;
state = authDaoWrap.deleteRolePermission(roleName, nodeName, permissionId);
return state;
}
/**
* Add role to user
*
* @param roleName
* @param username
* @return true: add role to user successfully, false: add role to user unsuccessfully
* @throws AuthException
*/
public static boolean grantRoleToUser(String roleName, String username) throws AuthException {
boolean state = false;
state = authDaoWrap.addUserRoleRel(username, roleName);
return state;
}
/**
* Delete role from user
*
* @param roleName
* @param username
* @return true: delete role from user successfully, false: delete role from user unsuccessfully
* @throws AuthException
*/
public static boolean revokeRoleFromUser(String roleName, String username) throws AuthException {
boolean state = false;
state = authDaoWrap.deleteUserRoleRel(username, roleName);
return state;
}
/**
* Get the all permission of the user
*
* @param username
* @param nodeName
* @return
* @throws AuthException
*/
public static Set<Integer> getPermission(String username, String nodeName) throws AuthException {
Set<Integer> permissionSets = null;
permissionSets = authDaoWrap.getAllUserPermissions(username, nodeName);
return permissionSets;
}
/**
* Modify the password
*
* @param username
* @param oldPassword
* @param newPassword
* @return true: update the password successfully, false: update the password unsuccessfully
* @throws AuthException
*/
public static boolean updateUserPassword(String username, String newPassword) throws AuthException {
boolean state = false;
state = authDaoWrap.updateUserPassword(username, newPassword);
if (state == false) {
throw new AuthException("The username or the password is not correct");
}
return state;
}
/**
* Check the permission belong to the user
*
* @param username
* @param nodeName
* @param permissionId
* @return true: the user has this permission, false: the user does not have the permission
*/
public static boolean checkUserPermission(String username, String nodeName, int permissionId) {
boolean state = false;
state = authDaoWrap.checkUserPermission(username, nodeName, permissionId);
return state;
}
}

View File

@ -0,0 +1,178 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.io.File;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import cn.edu.thu.tsfile.common.conf.TSFileDescriptor;
/**
* @author liukun
*
*/
public class DBdao {
private String derbyEmbeddedDriver = "org.apache.derby.jdbc.EmbeddedDriver";
private String protocal = "jdbc:derby:";
private String DBName;
private String createOrNot = ";create=true";
private String shutdown = ";shutdown=True";
private static Connection connection = null;
private static Statement statement = null;
private PreparedStatement preparedStatement = null;
/**
* @param dBName
*/
public DBdao(String dBName) {
String path = TSFileDescriptor.getInstance().getConfig().derbyHome + File.separator + dBName;
DBName = path;
}
public DBdao() {
this("derby-tsfile-db");
}
private void initDriver() {
try {
Class.forName(derbyEmbeddedDriver).newInstance();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
private void connection() {
String url = protocal + DBName + createOrNot;
try {
connection = DriverManager.getConnection(url);
} catch (SQLException e) {
e.printStackTrace();
}
}
private void closeConnection() {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
} else {
try {
throw new Exception("The connection is null");
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void statement() {
try {
statement = connection.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
}
private void closeStatement() {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
} else {
try {
throw new Exception("The statement is null");
} catch (Exception e) {
e.printStackTrace();
}
}
}
private boolean checkTableExist() {
boolean state = false;
try {
DatabaseMetaData metaData = connection.getMetaData();
ResultSet resultSet;
resultSet = metaData.getTables(null, "APP", "USERTABLE", null);
if (resultSet.next()) {
state = true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
// create table;
public boolean createOriTable() {
boolean state = false;
try {
statement.executeUpdate(InitTable.createTableSql);
statement.executeUpdate(InitTable.createRoleTableSql);
statement.executeUpdate(InitTable.createUserRoleRelTableSql);
statement.executeUpdate(InitTable.creteUserPermissionTableSql);
statement.executeUpdate(InitTable.createRolePermissionTableSql);
statement.executeUpdate(InitTable.insertIntoUserToTableSql);
state = true;
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public void getPreparedStatement() {
try {
preparedStatement = connection.prepareStatement("test");
} catch (SQLException e) {
e.printStackTrace();
}
}
public void closePreparedStatement() {
}
public void open() {
initDriver();
connection();
statement();
if (!checkTableExist()) {
//
createOriTable();
}
}
public void close() {
closeStatement();
closeConnection();
// try {
// DriverManager.getConnection(protocal + shutdown);
// } catch (SQLException e) {
// e.printStackTrace();
// }
}
public static Statement getStatement() {
return statement;
}
public static Connection getConnection() {
return connection;
}
}

View File

@ -0,0 +1,37 @@
package cn.edu.thu.tsfiledb.auth.dao;
/**
* @author liukun
*
*/
public class InitTable {
public static String createTableSql = "create table userTable("
+ "id INT generated always as identity(start with 1,increment by 1) not null primary key,"
+ "userName VARCHAR(20) not null unique," + "password VARCHAR(20) not null,"
+ "locked CHAR(1) check (locked='t' or locked='f')," + "validTime VARCHAR(20))";
public static String createRoleTableSql = "create table roleTable("
+ "id INT generated always as identity(start with 1, increment by 1) not null primary key,"
+ "roleName VARCHAR(20) not null unique)";
public static String createUserRoleRelTableSql = "create table userRoleRelTable("
+ "id INT generated always as identity(start with 1, increment by 1) ," + "userId INT," + "roleId INT,"
+ "constraint pk_userrolerel primary key (userId,roleId),"
+ "foreign key (userId) references usertable(id) on delete cascade,"
+ "foreign key (roleId) references roletable(id) on delete cascade)";
public static String creteUserPermissionTableSql = "create table userPermissionTable("
+ "id INT generated always as identity(start with 1,increment by 1) ," + "userId INT not null,"
+ "nodeName VARCHAR(20) not null," + "permissionId INT not null,"
+ "constraint pk_userpermission primary key (userId,nodeName,permissionId),"
+ "foreign key (userId) references usertable(id) on delete cascade)";
public static String createRolePermissionTableSql = "create table rolePermissionTable("
+ "id INT generated always as identity(start with 1, increment by 1)," + "roleId INT not null,"
+ "nodeName VARCHAR(20) not null," + "permissionId INT not null,"
+ "constraint pk_rolepermission primary key (roleId,nodeName,permissionId),"
+ "foreign key (roleId) references roleTable(id) on delete cascade)";
public static String insertIntoUserToTableSql = "insert into usertable (username,password) values('root','root')";
}

View File

@ -0,0 +1,103 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import cn.edu.thu.tsfiledb.auth.model.DBContext;
import cn.edu.thu.tsfiledb.auth.model.Role;
/**
* @author liukun
*
*/
public class RoleDao {
public List<Role> getRoles(Statement statement) {
ArrayList<Role> arrayList = new ArrayList<>();
String sql = "select * from " + DBContext.roleTable;
try {
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
Role role = new Role();
int id = resultSet.getInt(1);
String roleName = resultSet.getString(2);
role.setId(id);
role.setRoleName(roleName);
arrayList.add(role);
}
} catch (SQLException e) {
e.printStackTrace();
}
return arrayList;
}
public Role getRole(Statement statement, String roleName) {
String sql = "select * from " + DBContext.roleTable + " where roleName=" + "'" + roleName + "'";
Role role = null;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
role = new Role(id, name);
}
} catch (SQLException e) {
e.printStackTrace();
}
return role;
}
public Role getRole(Statement statement, int roleId) {
String sql = "select * from " + DBContext.roleTable + " where id=" + roleId;
Role role = null;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
role = new Role(roleId, resultSet.getString(2));
}
} catch (SQLException e) {
e.printStackTrace();
}
return role;
}
public int deleteRole(Statement statement, String roleName) {
String sql = "delete from " + DBContext.roleTable + " where roleName=" + "'" + roleName + "'";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int createRole(Statement statement, Role role) {
String sql = "insert into " + DBContext.roleTable + " (" + "roleName" + ")" + " values('" + role.getRoleName()
+ "')";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int updateRole(Statement statement) {
String sql = "update " + DBContext.roleTable + " set ";
int state = 0;
return state;
}
}

View File

@ -0,0 +1,99 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import cn.edu.thu.tsfiledb.auth.model.DBContext;
import cn.edu.thu.tsfiledb.auth.model.RolePermission;
/**
* @author liukun
*
*/
public class RolePermissionDao {
public int createRolePermission(Statement statement, RolePermission rolePermission) {
String sql = "insert into " + DBContext.rolePermission + " (roleId,nodeName,permissionId) values" + "("
+ rolePermission.getRoleId() + ",'" + rolePermission.getNodeName() + "',"
+ rolePermission.getPermissionId() + ")";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int deleteRolePermission(Statement statement, RolePermission rolePermission) {
String sql = "delete from " + DBContext.rolePermission + " where roleId=" + rolePermission.getRoleId() + " and "
+ "nodeName=" + "'" + rolePermission.getNodeName() + "'" + " and " + "permissionId="
+ rolePermission.getPermissionId();
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public RolePermission getRolePermission(Statement statement, RolePermission rolePermission) {
String sql = "select * from " + DBContext.rolePermission + " where roleId=" + rolePermission.getRoleId()
+ " and nodeName='" + rolePermission.getNodeName() + "' and permissionId="
+ rolePermission.getPermissionId();
RolePermission permission = null;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
permission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2), resultSet.getString(3),
resultSet.getInt(4));
}
} catch (SQLException e) {
e.printStackTrace();
}
return permission;
}
public List<RolePermission> getRolePermissions(Statement statement) {
String sql = "select * from " + DBContext.rolePermission;
List<RolePermission> rolePermissions = new ArrayList<>();
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
RolePermission rolePermission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2),
resultSet.getString(3), resultSet.getInt(4));
rolePermissions.add(rolePermission);
}
} catch (SQLException e) {
e.printStackTrace();
}
return rolePermissions;
}
public List<RolePermission> getRolePermissionByRoleAndNodeName(Statement statement, int roleId, String nodeName) {
String sql = "select * from " + DBContext.rolePermission + " where roleId=" + roleId + " and nodeName='"
+ nodeName + "'";
List<RolePermission> rolePermissions = new ArrayList<>();
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
RolePermission rolePermission = new RolePermission(resultSet.getInt(1), resultSet.getInt(2),
resultSet.getString(3), resultSet.getInt(4));
rolePermissions.add(rolePermission);
}
} catch (SQLException e) {
e.printStackTrace();
}
return rolePermissions;
}
}

View File

@ -0,0 +1,116 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import cn.edu.thu.tsfiledb.auth.model.DBContext;
import cn.edu.thu.tsfiledb.auth.model.User;
/**
* @author liukun
*
*/
public class UserDao {
public int createUser(Statement statement, User user) {
String sql = "insert into " + DBContext.userTable + " (userName,passWord) " + " values ('" + user.getUserName()
+ "','" + user.getPassWord() + "')";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int deleteUser(Statement statement, String userName) {
String sql = "delete from " + DBContext.userTable + " where userName=" + "'" + userName + "'";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int updateUserPassword(Statement statement, String userName, String newPassword) {
String sql = "update " + DBContext.userTable + " set password='" + newPassword + "'" + " where username='"
+ userName + "'";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public List<User> getUsers(Statement statement) {
String sql = "select * from " + DBContext.userTable;
ArrayList<User> arrayList = new ArrayList<>();
try {
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt(1);
String userName = resultSet.getString(2);
String passWord = resultSet.getString(3);
boolean isLock = resultSet.getBoolean(4);
String validTime = resultSet.getString(5);
User user = new User(id, userName, passWord, isLock, validTime);
arrayList.add(user);
}
} catch (SQLException e) {
e.printStackTrace();
}
return arrayList;
}
public User getUser(Statement statement, String userName) {
String sql = "select * from " + DBContext.userTable + " where userName=" + "'" + userName + "'";
User user = null;
try {
ResultSet resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
int id = resultSet.getInt(1);
String name = userName;
String passWord = resultSet.getString(3);
boolean isLock = resultSet.getBoolean(4);
String validTime = resultSet.getString(5);
user = new User(id, name, passWord, isLock, validTime);
}
} catch (SQLException e) {
e.printStackTrace();
}
return user;
}
public User getUser(Statement statement, String userName, String password) {
User user = null;
String sql = "select * from " + DBContext.userTable + " where username='" + userName + "'" + " and password='"
+ password + "'";
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
user = new User();
user.setId(resultSet.getInt(1));
user.setUserName(resultSet.getString(2));
user.setPassWord(resultSet.getString(3));
}
} catch (SQLException e) {
e.printStackTrace();
}
return user;
}
}

View File

@ -0,0 +1,99 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import cn.edu.thu.tsfiledb.auth.model.DBContext;
import cn.edu.thu.tsfiledb.auth.model.UserPermission;
/**
* @author liukun
*
*/
public class UserPermissionDao {
public int createUserPermission(Statement statement, UserPermission userPermission) {
String sql = "insert into " + DBContext.userPermission + " (userId,nodeName,permissionId)" + " values("
+ userPermission.getUserId() + ",'" + userPermission.getNodeName() + "',"
+ userPermission.getPermissionId() + ")";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int deleteUserPermission(Statement statement, UserPermission userPermission) {
String sql = "delete from " + DBContext.userPermission + " where userId=" + userPermission.getUserId() + " and "
+ "nodeName=" + "'" + userPermission.getNodeName() + "'" + " and " + "permissionId="
+ userPermission.getPermissionId();
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public UserPermission getUserPermission(Statement statement, UserPermission userPermission) {
String sql = "select * from " + DBContext.userPermission + " where userId=" + userPermission.getUserId()
+ " and " + "nodeName=" + "'" + userPermission.getNodeName() + "'" + " and " + "permissionId="
+ userPermission.getPermissionId();
UserPermission permission = null;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
permission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2), resultSet.getString(3),
resultSet.getInt(4));
}
} catch (SQLException e) {
e.printStackTrace();
}
return permission;
}
//
public ArrayList<UserPermission> getUserPermissionByUserAndNodeName(Statement statement, int userId,
String nodeName) {
ArrayList<UserPermission> userPermissions = new ArrayList<>();
String sql = "select * from " + DBContext.userPermission + " where userId=" + userId + " and " + "nodeName="
+ "'" + nodeName + "'";
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
UserPermission userPermission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2),
resultSet.getString(3), resultSet.getInt(4));
userPermissions.add(userPermission);
}
} catch (SQLException e) {
e.printStackTrace();
}
return userPermissions;
}
public List<UserPermission> getUserPermissions(Statement statement) {
ArrayList<UserPermission> userPermissions = new ArrayList<>();
String sql = "select * from " + DBContext.userPermission;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
UserPermission userPermission = new UserPermission(resultSet.getInt(1), resultSet.getInt(2),
resultSet.getString(3), resultSet.getInt(4));
userPermissions.add(userPermission);
}
} catch (SQLException e) {
e.printStackTrace();
}
return userPermissions;
}
}

View File

@ -0,0 +1,117 @@
package cn.edu.thu.tsfiledb.auth.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import cn.edu.thu.tsfiledb.auth.model.DBContext;
import cn.edu.thu.tsfiledb.auth.model.UserRoleRel;
/**
* @author liukun
*
*/
public class UserRoleRelDao {
public List<UserRoleRel> getUserRoleRels(Statement statement) {
String sql = "select * from " + DBContext.userRoleRel;
ArrayList<UserRoleRel> arrayList = new ArrayList<>();
try {
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt(1);
int userId = resultSet.getInt(2);
int roleId = resultSet.getInt(3);
UserRoleRel rel = new UserRoleRel(id, userId, roleId);
arrayList.add(rel);
}
} catch (SQLException e) {
e.printStackTrace();
}
return arrayList;
}
public UserRoleRel getUserRoleRel(Statement statement, UserRoleRel rel) {
String sql = "select * from " + DBContext.userRoleRel + " where userId=" + rel.getUserId() + " and roleId="
+ rel.getRoleId();
UserRoleRel userRoleRel = null;
ResultSet resultSet;
try {
resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
userRoleRel = new UserRoleRel(resultSet.getInt(1), resultSet.getInt(2), resultSet.getInt(3));
}
} catch (SQLException e) {
e.printStackTrace();
}
return userRoleRel;
}
public List<UserRoleRel> getUserRoleRelByUser(Statement statement, int userId) {
String sql = "select * from " + DBContext.userRoleRel + " where userId = " + userId;
ArrayList<UserRoleRel> arrayList = new ArrayList<>();
try {
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt(1);
int roleId = resultSet.getInt(3);
UserRoleRel rel = new UserRoleRel(id, userId, roleId);
arrayList.add(rel);
}
} catch (SQLException e) {
e.printStackTrace();
}
return arrayList;
}
public List<UserRoleRel> getUserRoleRelByRole(Statement statement, int roleId) {
String sql = "select * from " + DBContext.userRoleRel + " where roleId=" + roleId;
ArrayList<UserRoleRel> arrayList = new ArrayList<>();
try {
ResultSet resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
int id = resultSet.getInt(1);
int userId = resultSet.getInt(2);
UserRoleRel rel = new UserRoleRel(id, userId, roleId);
arrayList.add(rel);
}
} catch (SQLException e) {
e.printStackTrace();
}
return arrayList;
}
public int createUserRoleRel(Statement statement, UserRoleRel rel) {
String sql = "insert into " + DBContext.userRoleRel + " (userId,roleId) values" + "(" + rel.getUserId() + ","
+ rel.getRoleId() + ")";
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
public int deleteUserRoleRel(Statement statement, UserRoleRel rel) {
String sql = "delete from " + DBContext.userRoleRel + " where userId=" + rel.getUserId() + " and roleId="
+ rel.getRoleId();
int state = 0;
try {
state = statement.executeUpdate(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return state;
}
}

View File

@ -0,0 +1,28 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* The exception for authority model
* Created by liukun on 17/1/4.
*/
public class AuthException extends Exception {
public AuthException(String format, String userName, String roleName) {
super();
}
public AuthException(String message) {
super(message);
}
public AuthException(String message, Throwable cause) {
super(message, cause);
}
public AuthException(Throwable cause) {
super(cause);
}
protected AuthException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,16 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* The
* @author liukun
*
*/
public class DBContext {
public static final String userTable = "userTable";
public static final String roleTable = "roleTable";
public static final String userRoleRel = "userRoleRelTable";
public static final String userPermission = "userPermissionTable";
public static final String rolePermission = "rolePermissionTable";
}

View File

@ -0,0 +1,15 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class Permission {
public static final int CREATE = 0;
public static final int INSERT = 1;
public static final int MODIFY = 2;
public static final int READ = 3;
public static final int DELETE = 4;
}

View File

@ -0,0 +1,57 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class Role {
private int id;
private String roleName;
/**
* @param id
* @param roleName
*/
public Role(int id, String roleName) {
this.id = id;
this.roleName = roleName;
}
public Role(String roleName) {
this.roleName = roleName;
}
public Role(){
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the roleName
*/
public String getRoleName() {
return roleName;
}
/**
* @param roleName the roleName to set
*/
public void setRoleName(String roleName) {
this.roleName = roleName;
}
}

View File

@ -0,0 +1,96 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class RolePermission {
private int id;
private int roleId;
private String nodeName;
private int permissionId;
/**
* @param id
* @param roleId
* @param permissionId
*/
public RolePermission(int id, int roleId, String nodeName, int permissionId) {
this.id = id;
this.roleId = roleId;
this.nodeName = nodeName;
this.permissionId = permissionId;
}
public RolePermission(int roleId, String nodeName, int permissionId) {
this.roleId = roleId;
this.nodeName = nodeName;
this.permissionId = permissionId;
}
public RolePermission() {
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the nodeName
*/
public String getNodeName() {
return nodeName;
}
/**
* @param nodeName
* the nodeName to set
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
/**
* @return the roleId
*/
public int getRoleId() {
return roleId;
}
/**
* @param roleId
* the roleId to set
*/
public void setRoleId(int roleId) {
this.roleId = roleId;
}
/**
* @return the permissionId
*/
public int getPermissionId() {
return permissionId;
}
/**
* @param permissionId
* the permissionId to set
*/
public void setPermissionId(int permissionId) {
this.permissionId = permissionId;
}
}

View File

@ -0,0 +1,109 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class User {
private int id;
private String userName;
private String passWord;
private boolean locked;//true - t false - f
private String validTime;
/**
* @param id
* @param userName
* @param passWord
* @param isLock
* @param validTime
*/
public User(int id, String userName, String passWord, boolean isLock, String validTime) {
this.id = id;
this.userName = userName;
this.passWord = passWord;
this.locked = isLock;
this.validTime = validTime;
}
public User(){
}
public User(String userName, String passWord) {
this.userName = userName;
this.passWord = passWord;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the userName
*/
public String getUserName() {
return userName;
}
/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* @return the passWord
*/
public String getPassWord() {
return passWord;
}
/**
* @param passWord the passWord to set
*/
public void setPassWord(String passWord) {
this.passWord = passWord;
}
/**
* @return the isLock
*/
public boolean isLock() {
return locked;
}
/**
* @param isLock the isLock to set
*/
public void setLock(boolean isLock) {
this.locked = isLock;
}
/**
* @return the validTime
*/
public String getValidTime() {
return validTime;
}
/**
* @param validTime the validTime to set
*/
public void setValidTime(String validTime) {
this.validTime = validTime;
}
}

View File

@ -0,0 +1,98 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class UserPermission {
private int id;
private int userId;
private String nodeName;
private int permissionId;// 权限的值必须是permission中的在数据库中使用check方法来指定
/**
* @param id
* @param userId
* @param nodeName
* @param permissionId
*/
public UserPermission(int id, int userId, String nodeName, int permissionId) {
this.id = id;
this.userId = userId;
this.nodeName = nodeName;
this.permissionId = permissionId;
}
public UserPermission() {
}
public UserPermission(int userId, String nodeName, int permissionId) {
this.userId = userId;
this.nodeName = nodeName;
this.permissionId = permissionId;
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the userId
*/
public int getUserId() {
return userId;
}
/**
* @param userId
* the userId to set
*/
public void setUserId(int userId) {
this.userId = userId;
}
/**
* @return the nodeName
*/
public String getNodeName() {
return nodeName;
}
/**
* @param nodeName
* the nodeName to set
*/
public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}
/**
* @return the permissionId
*/
public int getPermissionId() {
return permissionId;
}
/**
* @param permissionId
* the permissionId to set
*/
public void setPermissionId(int permissionId) {
this.permissionId = permissionId;
}
}

View File

@ -0,0 +1,65 @@
package cn.edu.thu.tsfiledb.auth.model;
/**
* @author liukun
*
*/
public class UserRoleRel {
private int id;
private int userId;
private int roleId;
/**
* @param id
* @param userId
* @param roleId
*/
public UserRoleRel(int id, int userId, int roleId) {
this.id = id;
this.userId = userId;
this.roleId = roleId;
}
public UserRoleRel(int userId,int roleId){
this.userId = userId;
this.roleId = roleId;
}
public UserRoleRel() {
}
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the userId
*/
public int getUserId() {
return userId;
}
/**
* @param userId the userId to set
*/
public void setUserId(int userId) {
this.userId = userId;
}
/**
* @return the roleId
*/
public int getRoleId() {
return roleId;
}
/**
* @param roleId the roleId to set
*/
public void setRoleId(int roleId) {
this.roleId = roleId;
}
}

View File

@ -0,0 +1,229 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLTimeoutException;
import java.sql.Statement;
import jline.console.ConsoleReader;
public class Client {
private static final int MAX_PRINT_ROW_COUNT = 1000;
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
Class.forName("com.corp.tsfile.jdbc.TsfileDriver");
Connection connection = null;
ConsoleReader reader = null;
String s;
boolean printToConsole = true;
try {
reader = new ConsoleReader();
String[] argsName = new String[] { "-host", "-port", "-u", "-print" };
String[] argv = new String[argsName.length];
if (args.length < 3) {
System.out.println("Useage : login -host<host> -port<port> -u<username>");
System.out.println("e.g. : login -host127.0.0.1 -port6667 -u<UserA>");
return;
}
for (int i = 0; i < args.length; i++) {
String v = args[i].trim();
for (int j = 0; j < argsName.length; j++) {
if (v.startsWith(argsName[j])) {
argv[j] = v.substring(argsName[j].length()).trim();
}
}
}
if (argv[3] != null && !argv[3].equals("")) {
if (argv[3].toLowerCase().equals("true") || argv[3].toLowerCase().equals("false")) {
printToConsole = Boolean.valueOf(argv[3]);
} else {
System.out.println("-print args error.");
return;
}
}
String password = reader.readLine("Password: ", ' ');
try {
connection = DriverManager.getConnection("jdbc:tsfile://" + argv[0] + ":" + argv[1] + "/x", argv[2],
password);
} catch (SQLTimeoutException e){
System.out.println("Connect Timeout: " + e.getMessage());
return;
} catch (SQLException e) {
System.out.println(e.getMessage());
return;
}
} catch (IOException e) {
System.out.println("Console Input Error:" + e.getMessage());
} catch (Exception e){
System.out.println("Unknown Error: " + e.getMessage());
}
System.out.println(" _______________________________.___.__ \n"
+ " \\__ ___/ _____/\\_ _____/| | | ____ \n"
+ " | | \\_____ \\ | __) | | | _/ __ \\ \n"
+ " | | / \\ | \\ | | |_\\ ___/ \n"
+ " |____| /_______ / \\___ / |___|____/\\___ > version 0.0.1\n"
+ " \\/ \\/ \\/ \n");
// Login in and create connection first
System.out.println("login successfully");
// connection =
// DriverManager.getConnection("jdbc:tsfile://127.0.0.1:6667/x",
// "User", "HAHAH");
try {
while (true) {
s = reader.readLine("[TSFile: ] > ");
if (s.toLowerCase().trim().equals("quit")) {
System.out.println(">> TSFile Quit");
break;
}
if (s.toLowerCase().trim().equals("show metadata")){
System.out.println(connection.getMetaData());
continue;
}
String[] cmds = s.split(";");
for (int i = 0; i < cmds.length; i++) {
String cmd = cmds[i];
if (cmd != null && !cmd.trim().equals("")) {
Statement statement = connection.createStatement();
statement.setFetchSize(500000);
try {
boolean hasResultSet = statement.execute(cmd.trim());
if (hasResultSet) {
ResultSet resultSet = statement.getResultSet();
output(resultSet, printToConsole);
}
statement.close();
System.out.println("Execute successfully.");
} catch (TsfileSQLException e) {
System.out.println("statement error: " + e.getMessage());
} catch (Exception e){
System.out.println("Connection error. " + e.getMessage());
}
}
}
}
connection.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public static void output(ResultSet res, boolean printToConsole) {
try {
File file = new File("src/main/resources/output/queryRes.csv");
if (!file.exists()) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
FileWriter fw = new FileWriter(file);
// BufferedWriter bw = new BufferedWriter(fw);
int cnt = 0;
int colCount = res.getMetaData().getColumnCount();
// //Output Labels
String format = "|%15s|";
String blockLine = "";
if (printToConsole) {
// System.out.printf("+---------------+");
// for(int i = 0 ; i < res.mapRet.keySet().size(); i++){
// System.out.printf("---------------+");
// }
// System.out.printf("\n");
//
// System.out.printf("|%15s|","Timestamp");
// for(String name : res.mapRet.keySet()){
// System.out.printf("%15s|", name.split(",")[1]);
// }
// System.out.printf("\n");
//
int maxv = 15;
for (int i = 0; i < colCount; i++) {
int len = res.getMetaData().getColumnLabel(i).length();
maxv = maxv < len ? len : maxv;
}
for (int i = 0; i < maxv; i++) {
blockLine += "-";
}
System.out.printf("+" + blockLine + "+");
for (int i = 0; i < colCount - 1; i++) {
System.out.printf(blockLine + "+");
}
System.out.printf("\n");
format = "%" + maxv + "s|";
System.out.printf("|" + format, "Timestamp");
for (int i = 0; i < colCount - 1; i++) {
System.out.printf(format, res.getMetaData().getColumnLabel(i + 1));
}
System.out.printf("\n");
System.out.printf("+" + blockLine + "+");
for (int i = 0; i < colCount - 1; i++) {
System.out.printf(blockLine + "+");
}
System.out.printf("\n");
}
// Output values
while (res.next()) {
StringBuilder line = new StringBuilder();
line.append(String.valueOf(res.getString(0)));
if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) {
System.out.printf("|" + format, String.valueOf(res.getString(0)));
}
for (int i = 1; i < colCount; i++) {
line.append(",");
line.append(res.getString(i));
if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) {
System.out.printf(format, String.valueOf(res.getString(i)));
}
}
if (printToConsole && cnt < MAX_PRINT_ROW_COUNT) {
System.out.printf("\n");
}
// bw.write(line.toString());
// bw.newLine();
cnt++;
if (!printToConsole && cnt % 10000 == 0) {
System.out.println(cnt);
}
}
if (printToConsole) {
System.out.printf("+" + blockLine + "+");
for (int i = 0; i < colCount - 1; i++) {
System.out.printf(blockLine + "+");
}
System.out.printf("\n");
}
// bw.close();
System.out.println("Result size : " + cnt);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}

View File

@ -0,0 +1,41 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Demo {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
Class.forName("com.corp.tsfile.jdbc.TsfileDriver");
Connection connection = DriverManager.getConnection("jdbc:tsfile://127.0.0.1:6667/", "root", "root");
// Statement statement = connection.createStatement();
// statement.addBatch("123");
// statement.addBatch("321");
// int[] resultSet = statement.executeBatch();
// System.out.println(resultSet.length);
// statement.clearBatch();
// connection.close();
//
// Connection connection = DriverManager.getConnection("jdbc:tsfile://192.168.130.15:6667/","root","root");
DatabaseMetaData databaseMetaData = connection.getMetaData();
System.out.println("show metadata");
System.out.println(databaseMetaData);
// get all columns
ResultSet resultSet = databaseMetaData.getColumns(null, null, "car", null);
while(resultSet.next()){
System.out.println(String.format("column %s, type %s", resultSet.getString("COLUMN_NAME"), resultSet.getString("COLUMN_TYPE")));
}
// get all delta object
resultSet = databaseMetaData.getColumns(null, null, null, "car");
while(resultSet.next()){
System.out.println(String.format("delta object %s", resultSet.getString("DELTA_OBJECT")));
}
connection.close();
}
}

View File

@ -0,0 +1,137 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.lang.management.ManagementFactory;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.management.OperatingSystemMXBean;
import cn.edu.thu.tsfile.file.metadata.enums.TSDataType;
import cn.edu.thu.tsfile.file.metadata.enums.TSEncoding;
@SuppressWarnings("restriction")
public class Generator {
private static final Logger LOGGER = LoggerFactory.getLogger(Generator.class);
private String deviceName;
private OperatingSystemMXBean osmb;
private final String createTimeSeriesTemplate = "create timeseries root.%s.laptop.%s with datatype=%s,encoding=%s";
private final String insertDataTemplate = "insert into root.%s.laptop.%s values(%s,%s)";
private final String queryDataTemplate = "select laptop.* from root.%s where time < %s";
private final String setFileLevelTemplate = "set storage group to root.%s.laptop";
private final long SLEEP_INTERVAL = 5000;
// private final String JDBC_SERVER_URL = "jdbc:tsfile://127.0.0.1:6667/x";
private final String JDBC_SERVER_URL = "jdbc:tsfile://192.168.130.15:6667/x";
public Generator(String deviceName) {
this.deviceName = deviceName;
this.osmb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
}
public void start() throws ClassNotFoundException, SQLException {
Class.forName("com.corp.tsfile.jdbc.TsfileDriver");
createTimeSeriesMetadata();
while (true) {
try {
insertData();
Thread.sleep(SLEEP_INTERVAL);
} catch (SQLException e) {
LOGGER.error("tsfile-jdbc Generator: insertData failed because ", e);
} catch (InterruptedException e) {
LOGGER.error("tsfile-jdbc Generator: thread sleep failed because ", e);
}
}
}
public void test() throws SQLException, ClassNotFoundException {
Class.forName("com.corp.tsfile.jdbc.TsfileDriver");
Connection connection = DriverManager.getConnection(JDBC_SERVER_URL, "root", "root");
Statement statement = connection.createStatement();
ResultSet res = statement.executeQuery(String.format(queryDataTemplate, deviceName, getCurretnTimestamp()));
Client.output(res, true);
connection.close();
}
private void createTimeSeriesMetadata() throws SQLException {
List<String> sqls = new ArrayList<>();
sqls.add(String.format(createTimeSeriesTemplate, deviceName, "cpu", TSDataType.FLOAT.toString(),
TSEncoding.RLE.toString()));
sqls.add(String.format(createTimeSeriesTemplate, deviceName, "memory", TSDataType.INT64.toString(),
TSEncoding.RLE.toString()));
sqls.add(String.format(setFileLevelTemplate, deviceName));
executeSQL(sqls);
}
private void insertData() throws SQLException {
List<String> sqls = new ArrayList<>();
String timestamp = String.valueOf(getCurretnTimestamp());
sqls.add(String.format(insertDataTemplate, deviceName, "cpu", timestamp, getCpuRatio()));
sqls.add(String.format(insertDataTemplate, deviceName, "memory", timestamp, getFreePhysicalMemorySize()));
executeSQL(sqls);
}
private void executeSQL(List<String> sqls) throws SQLException {
Connection connection = null;
try {
connection = DriverManager.getConnection(JDBC_SERVER_URL, "root", "root");
Statement statement = connection.createStatement();
for (String sql : sqls) {
try {
statement.execute(sql);
} catch (Exception e) {
LOGGER.error("tsfile-jdbc Generator: execute {} failed!", sql, e);
continue;
}
LOGGER.info("tsfile-jdbc Generator: execute {} successfully!", sql);
}
} catch (SQLException e) {
LOGGER.error("tsfile-jdbc Generator: fail to execute {} because ", sqls, e);
} finally {
if (connection != null) {
connection.close();
connection = null;
}
}
}
public String getCpuRatio() {
double cpuRatio = osmb.getSystemCpuLoad() * 100;
if (cpuRatio < 0 || cpuRatio > 100) {
return "0";
}
return String.format("%.2f", cpuRatio);
}
private String getFreePhysicalMemorySize() {
long sizeFree = osmb.getFreePhysicalMemorySize();
return sizeFree > 0 ? String.valueOf(sizeFree) : "0";
}
private String getCurretnTimestamp() {
return String.valueOf(System.currentTimeMillis());
}
public static void main(String[] args) throws ClassNotFoundException, SQLException, InterruptedException {
Generator demo = new Generator("caogaofei_pc");
// insert data
demo.start();
// query data
// demo.test();
}
}

View File

@ -0,0 +1,31 @@
package cn.edu.thu.tsfiledb.jdbc;
public class TsfileConfig {
/**
* The required prefix for the connection URL.
*/
public static final String TSFILE_URL_PREFIX = "jdbc:tsfile://";
public static final String TSFILE_DEFAULT_HOST = "localhost";
/**
* If host is provided, without a port.
*/
public static final int TSFILE_DEFAULT_PORT = 8888;
/**
* tsfile's default series name
*/
public static final String DEFAULT_SERIES_NAME = "default";
public static final String URI_JDBC_PREFIX = "jdbc:";
public static final String URI_TSFILE_PREFIX = "tsfile:";
public static final int DEFAULT_FETCH_SIZE = 1000;
public static final String AUTH_USER = "user";
public static final String DEFAULT_USER = "user";
public static final String AUTH_PASSWORD = "password";
public static final String DEFALUT_PASSWORD = "password";
}

View File

@ -0,0 +1,454 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
import cn.edu.thu.tsfiledb.metadata.ColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TsfileConnection implements Connection {
private static final Logger LOGGER = LoggerFactory.getLogger(TsfileConnection.class);
private TsfileConnectionParams params;
private boolean isClosed = true;
private SQLWarning warningChain = null;
private TTransport transport;
private TSIService.Iface client = null;
private TS_SessionHandle sessionHandle = null;
private final List<TSProtocolVersion> supportedProtocols = new LinkedList<TSProtocolVersion>();
// private int loginTimeout = 0;
private TSProtocolVersion protocol;
public TsfileConnection(String url, Properties info) throws SQLException, TTransportException {
if (url == null) {
throw new TsfileURLException("Input url cannot be null");
}
params = Utils.parseURL(url, info);
supportedProtocols.add(TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1);
openTransport();
client = new TSIService.Client(new TBinaryProtocol(transport));
// open client session
openSession();
// Wrap the client with a thread-safe proxy to serialize the RPC calls
client = newSynchronizedClient(client);
}
@Override
public boolean isWrapperFor(Class<?> arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public <T> T unwrap(Class<T> arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void abort(Executor arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void clearWarnings() throws SQLException {
warningChain = null;
}
@Override
public void close() throws SQLException {
if (isClosed)
return;
TSCloseSessionReq req = new TSCloseSessionReq(sessionHandle);
try {
client.CloseSession(req);
} catch (TException e) {
throw new SQLException("Error occurs when closing session at server", e);
} finally {
isClosed = true;
if (transport != null)
transport.close();
}
}
@Override
public void commit() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Array createArrayOf(String arg0, Object[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Blob createBlob() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Clob createClob() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public NClob createNClob() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public SQLXML createSQLXML() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Statement createStatement() throws SQLException {
if (isClosed) {
throw new SQLException("Cannot create statement because connection is closed");
}
return new TsfileStatement(this, client, sessionHandle);
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
throw new SQLException(String.format("Statement with resultset concurrency %d is not supported", resultSetConcurrency));
}
if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
throw new SQLException(String.format("Statement with resultset type %d is not supported", resultSetType));
}
return new TsfileStatement(this, client, sessionHandle);
}
@Override
public Statement createStatement(int arg0, int arg1, int arg2) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Struct createStruct(String arg0, Object[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean getAutoCommit() throws SQLException {
return false;
}
@Override
public String getCatalog() throws SQLException {
return "no cata log";
}
@Override
public Properties getClientInfo() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public String getClientInfo(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getHoldability() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public DatabaseMetaData getMetaData() throws SQLException {
if (isClosed) {
throw new SQLException("Cannot create statement because connection is closed");
}
try {
TSFetchMetadataResp resp = client.FetchMetadata(new TSFetchMetadataReq());
Utils.verifySuccess(resp.getStatus());
Map<String, List<ColumnSchema>> seriesMap = Utils.convertAllSchema(resp.getSeriesMap());
Map<String, List<String>> deltaObjectMap = resp.getDeltaObjectMap();
String metadataInJson = resp.getMetadataInJson();
return new TsfileDatabaseMetadata(this, seriesMap, deltaObjectMap, metadataInJson);
} catch (TException e) {
throw new SQLException("Fail to connect to server when fetching metadata because "+e.getMessage());
} catch (Exception e){
throw new SQLException("Error occurs when fetching metaData because " + e.getMessage());
}
}
@Override
public int getNetworkTimeout() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public String getSchema() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getTransactionIsolation() throws SQLException {
return Connection.TRANSACTION_NONE;
}
@Override
public Map<String, Class<?>> getTypeMap() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public SQLWarning getWarnings() throws SQLException {
return warningChain;
}
@Override
public boolean isClosed() throws SQLException {
return isClosed;
}
@Override
public boolean isReadOnly() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean isValid(int arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public String nativeSQL(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public CallableStatement prepareCall(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public CallableStatement prepareCall(String arg0, int arg1, int arg2) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public CallableStatement prepareCall(String arg0, int arg1, int arg2, int arg3) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void releaseSavepoint(Savepoint arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void rollback() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void rollback(Savepoint arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setAutoCommit(boolean arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setCatalog(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setClientInfo(Properties arg0) throws SQLClientInfoException {
throw new SQLClientInfoException("Method not supported", null);
}
@Override
public void setClientInfo(String arg0, String arg1) throws SQLClientInfoException {
throw new SQLClientInfoException("Method not supported", null);
}
@Override
public void setHoldability(int arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setNetworkTimeout(Executor arg0, int arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setReadOnly(boolean arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Savepoint setSavepoint() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Savepoint setSavepoint(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setSchema(String arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setTransactionIsolation(int arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setTypeMap(Map<String, Class<?>> arg0) throws SQLException {
throw new SQLException("Method not supported");
}
private void openTransport() throws TTransportException {
transport = new TSocket(params.getHost(), params.getPort());
if (!transport.isOpen()) {
transport.open();
LOGGER.debug("Connect to host {} port {}",params.getHost(),params.getPort());
}
}
private void openSession() throws SQLException {
TSOpenSessionReq openReq = new TSOpenSessionReq(TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1);
openReq.setUsername(params.getUsername());
openReq.setPassword(params.getPassword());
try {
TSOpenSessionResp openResp = client.OpenSession(openReq);
// validate connection
Utils.verifySuccess(openResp.getStatus());
if (!supportedProtocols.contains(openResp.getServerProtocolVersion())) {
throw new TException("Unsupported tsfile protocol");
}
setProtocol(openResp.getServerProtocolVersion());
sessionHandle = openResp.getSessionHandle();
} catch (TException e) {
throw new SQLException(String.format("Can not establish connection with %s. because %s",
params.getJdbcUriString()), e.getMessage());
}
isClosed = false;
}
public static TSIService.Iface newSynchronizedClient(TSIService.Iface client) {
return (TSIService.Iface) Proxy.newProxyInstance(TsfileConnection.class.getClassLoader(),
new Class[] { TSIService.Iface.class }, new SynchronizedHandler(client));
}
public TSProtocolVersion getProtocol() {
return protocol;
}
public void setProtocol(TSProtocolVersion protocol) {
this.protocol = protocol;
}
private static class SynchronizedHandler implements InvocationHandler {
private final TSIService.Iface client;
SynchronizedHandler(TSIService.Iface client) {
this.client = client;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
synchronized (client) {
return method.invoke(client, args);
}
} catch (InvocationTargetException e) {
// all IFace APIs throw TException
if (e.getTargetException() instanceof TException) {
throw (TException) e.getTargetException();
} else {
// should not happen
throw new TException("Error in calling method " + method.getName(), e.getTargetException());
}
} catch (Exception e) {
throw new TException("Error in calling method " + method.getName(), e);
}
}
}
}

View File

@ -0,0 +1,59 @@
package cn.edu.thu.tsfiledb.jdbc;
public class TsfileConnectionParams {
private String host = TsfileConfig.TSFILE_DEFAULT_HOST;
private int port = TsfileConfig.TSFILE_DEFAULT_PORT;
private String jdbcUriString;
private String seriesName = TsfileConfig.DEFAULT_SERIES_NAME;
private String username = TsfileConfig.DEFAULT_USER;
private String password = TsfileConfig.DEFALUT_PASSWORD;
private String dbName;
public TsfileConnectionParams(String url){
this.jdbcUriString = url;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public String getJdbcUriString() {
return jdbcUriString;
}
public void setJdbcUriString(String jdbcUriString) {
this.jdbcUriString = jdbcUriString;
}
public String getSeriesName() {
return seriesName;
}
public void setSeriesName(String seriesName) {
this.seriesName = seriesName;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDbName() {
return dbName;
}
public void setDbName(String dbName) {
this.dbName = dbName;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import org.apache.thrift.transport.TTransportException;
public class TsfileDriver implements Driver {
private static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger(TsfileDriver.class);
static {
try {
java.sql.DriverManager.registerDriver(new TsfileDriver());
} catch (SQLException e) {
LOGGER.error("Error occurs when resgistering tsfile driver",e);
}
}
/**
* Is this driver JDBC compliant?
*/
private static final boolean TSFILE_JDBC_COMPLIANT = false;
public TsfileDriver() {
}
@Override
public boolean acceptsURL(String url) throws SQLException {
return Pattern.matches(TsfileConfig.TSFILE_URL_PREFIX+".*", url);
}
@Override
public Connection connect(String url, Properties info) throws SQLException {
try {
return acceptsURL(url) ? new TsfileConnection(url, info) : null;
} catch (TTransportException e) {
throw new SQLException("Connection Error, Please check whether the network is avalible or the server has started. " + e.getMessage());
}
}
@Override
public int getMajorVersion() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getMinorVersion() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException("Method not supported");
}
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean jdbcCompliant() {
return TSFILE_JDBC_COMPLIANT;
}
}

View File

@ -0,0 +1,257 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.sql.Time;
import java.util.Iterator;
import java.util.List;
import cn.edu.thu.tsfiledb.metadata.ColumnSchema;
public class TsfileMetadataResultSet extends TsfileQueryResultSet {
private Iterator<?> columnItr;
private ColumnSchema currentColumn;
private String currentDeltaObject;
private MetadataType type;
public TsfileMetadataResultSet(List<ColumnSchema> columnSchemas, List<String> deltaObjectList) {
if (columnSchemas != null) {
columnItr = columnSchemas.iterator();
type = MetadataType.COLUMN;
} else if (deltaObjectList != null) {
columnItr = deltaObjectList.iterator();
type = MetadataType.DELTA_OBJECT;
}
}
@Override
public void close() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int findColumn(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public BigDecimal getBigDecimal(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean getBoolean(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean getBoolean(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public byte getByte(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public byte getByte(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public byte[] getBytes(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public byte[] getBytes(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getConcurrency() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Date getDate(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Date getDate(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public double getDouble(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public double getDouble(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getFetchDirection() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public float getFloat(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public float getFloat(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getInt(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getInt(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public long getLong(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public long getLong(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public ResultSetMetaData getMetaData() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean next() throws SQLException {
boolean hasNext = columnItr.hasNext();
switch (type) {
case COLUMN:
if (hasNext) {
currentColumn = (ColumnSchema)columnItr.next();
}
return hasNext;
case DELTA_OBJECT:
if (hasNext) {
currentDeltaObject = (String)columnItr.next();
}
return hasNext;
default:
break;
}
return false;
}
@Override
public Object getObject(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Object getObject(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public short getShort(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public short getShort(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Statement getStatement() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public String getString(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public String getString(String columnName) throws SQLException {
switch (columnName) {
case "COLUMN_NAME":
return currentColumn.name;
case "COLUMN_TYPE":
return currentColumn.dataType.toString();
case "DELTA_OBJECT":
return currentDeltaObject;
default:
break;
}
return null;
}
@Override
public Time getTime(int columnIndex) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Time getTime(String columnName) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getType() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public SQLWarning getWarnings() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean isClosed() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean wasNull() throws SQLException {
throw new SQLException("Method not supported");
}
private enum MetadataType{
DELTA_OBJECT, COLUMN;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,169 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Map;
public class TsfileResultMetadata implements ResultSetMetaData {
private Map<String, Integer> columnInfo;
public TsfileResultMetadata(Map<String, Integer> columnInfo) {
this.columnInfo = columnInfo;
}
@Override
public boolean isWrapperFor(Class<?> arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public <T> T unwrap(Class<T> arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getCatalogName(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getColumnClassName(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getColumnCount() throws SQLException {
if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) {
throw new SQLException("No column exists");
}
return columnInfo.keySet().size();
}
@Override
public int getColumnDisplaySize(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getColumnLabel(int column) throws SQLException {
if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) {
throw new SQLException("No column exists");
}
for (Map.Entry<String, Integer> entry : columnInfo.entrySet()) {
if (entry.getValue().equals(column)) {
return String.format(entry.getKey());
}
}
throw new SQLException(String.format("column %d does not exist", column));
}
@Override
public String getColumnName(int column) throws SQLException {
if (columnInfo == null || columnInfo.keySet() == null || columnInfo.keySet().size() == 0) {
throw new SQLException("tNo column exists");
}
for (Map.Entry<String, Integer> entry : columnInfo.entrySet()) {
if (entry.getValue().equals(column)) {
return entry.getKey();
}
}
throw new SQLException(String.format("column %d does not exist", column));
}
@Override
public int getColumnType(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getColumnTypeName(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public int getPrecision(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getScale(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getSchemaName(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTableName(int arg0) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isAutoIncrement(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isCaseSensitive(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isCurrency(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isDefinitelyWritable(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public int isNullable(int arg0) throws SQLException {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isReadOnly(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSearchable(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSigned(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isWritable(int arg0) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -0,0 +1,24 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.SQLException;
public class TsfileSQLException extends SQLException{
private String errorMessage;
/**
*
*/
private static final long serialVersionUID = -3306001287342258977L;
public TsfileSQLException(String reason){
super(reason);
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
}

View File

@ -0,0 +1,411 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.apache.thrift.TException;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle;
public class TsfileStatement implements Statement {
private ResultSet resultSet = null;
private final TsfileConnection connection;
private int fetchSize = TsfileConfig.DEFAULT_FETCH_SIZE;
private int queryTimeout = 10;
private TSIService.Iface client = null;
private TS_SessionHandle sessionHandle = null;
private TSOperationHandle operationHandle = null;
private List<String> batchSQLList;
/**
* Keep state so we can fail certain calls made after close().
*/
private boolean isClosed = false;
/**
* Keep state so we can fail certain calls made after cancel().
*/
private boolean isCancelled = false;
/**
* Sets the limit for the maximum number of rows that any ResultSet object
* produced by this Statement can contain to the given number. If the limit
* is exceeded, the excess rows are silently dropped. The value must be >=
* 0, and 0 means there is not limit.
*/
private int maxRows = 0;
/**
* Add SQLWarnings to the warningChain if needed.
*/
private SQLWarning warningChain = null;
public TsfileStatement(TsfileConnection connection, TSIService.Iface client, TS_SessionHandle sessionHandle,
int fetchSize) {
this.connection = connection;
this.client = client;
this.sessionHandle = sessionHandle;
this.fetchSize = fetchSize;
this.batchSQLList = new ArrayList<>();
}
public TsfileStatement(TsfileConnection connection, TSIService.Iface client, TS_SessionHandle sessionHandle){
this(connection, client, sessionHandle, TsfileConfig.DEFAULT_FETCH_SIZE);
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
throw new SQLException("Cannot unwrap to " + iface);
}
@Override
public void addBatch(String sql) throws SQLException {
if(batchSQLList == null){
batchSQLList = new ArrayList<>();
}
batchSQLList.add(sql);
}
@Override
public void cancel() throws SQLException {
checkConnection("cancle");
if(isCancelled) return;
try {
if (operationHandle != null) {
TSCancelOperationReq closeReq = new TSCancelOperationReq(operationHandle);
TSCancelOperationResp closeResp = client.CancelOperation(closeReq);
Utils.verifySuccess(closeResp.getStatus());
}
} catch (Exception e) {
throw new SQLException("Error occurs when cancling statement because "+e.getMessage());
}
isCancelled = true;
}
@Override
public void clearBatch() throws SQLException {
if(batchSQLList == null){
batchSQLList = new ArrayList<>();
}
batchSQLList.clear();
}
@Override
public void clearWarnings() throws SQLException {
warningChain = null;
}
public void closeClientOperation() throws SQLException{
try {
if (operationHandle != null) {
TSCloseOperationReq closeReq = new TSCloseOperationReq(operationHandle);
TSCloseOperationResp closeResp = client.CloseOperation(closeReq);
Utils.verifySuccess(closeResp.getStatus());
}
} catch (Exception e) {
throw new SQLException("Error occurs when closing statement because "+e.getMessage());
}
}
@Override
public void close() throws SQLException {
if(isClosed) return;
// if(resultSet != null){
// resultSet.close();
// resultSet = null;
// }else{
closeClientOperation();
// }
client = null;
isClosed = true;
}
@Override
public void closeOnCompletion() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean execute(String sql) throws SQLException {
checkConnection("execute");
try {
isCancelled = false;
TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql);
TSExecuteStatementResp execResp = client.ExecuteStatement(execReq);
operationHandle = execResp.getOperationHandle();
Utils.verifySuccess(execResp.getStatus());
if(execResp.getOperationHandle().hasResultSet){
resultSet = new TsfileQueryResultSet(this, execResp.getColumns(), client, sessionHandle,operationHandle, sql);
return true;
}
return false;
} catch (TException e) {
throw new TsfileSQLException(String.format("Fail to execute %s when connecting to server because %s", sql, e.getMessage()));
}
}
@Override
public boolean execute(String arg0, int arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean execute(String arg0, int[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public boolean execute(String arg0, String[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int[] executeBatch() throws SQLException {
checkConnection("executeBatch");
try {
isCancelled = false;
TSExecuteBatchStatementReq execReq = new TSExecuteBatchStatementReq(sessionHandle, batchSQLList);
TSExecuteBatchStatementResp execResp = client.ExecuteBatchStatement(execReq);
Utils.verifySuccess(execResp.getStatus());
if (execResp.getResult() == null){
return new int[0];
}
else{
List<Integer> result = execResp.getResult();
int len = result.size();
int[] updateArray = new int[len];
for(int i = 0; i < len; i++){
updateArray[i] = result.get(i);
}
return updateArray;
}
} catch (TException e) {
throw new TsfileSQLException(String.format("Fail to execute sqls in batch when connecting to server because %s",e.getMessage()));
}
}
@Override
public ResultSet executeQuery(String sql) throws SQLException {
checkConnection("execute");
try {
isCancelled = false;
TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql);
TSExecuteStatementResp execResp = client.ExecuteQueryStatement(execReq);
operationHandle = execResp.getOperationHandle();
Utils.verifySuccess(execResp.getStatus());
resultSet = new TsfileQueryResultSet(this,execResp.getColumns(), client,sessionHandle,operationHandle, sql);
} catch (TException e) {
throw new TsfileSQLException(String.format("Fail to execute query sql %s when connecting to server because %s",sql,e.getMessage()));
}
return resultSet;
}
@Override
public int executeUpdate(String sql) throws SQLException {
try {
TSExecuteStatementReq execReq = new TSExecuteStatementReq(sessionHandle, sql);
TSExecuteStatementResp execResp = client.ExecuteUpdateStatement(execReq);
operationHandle = execResp.getOperationHandle();
Utils.verifySuccess(execResp.getStatus());
} catch (TException e) {
throw new TsfileSQLException(String.format("Fail to execute update sql %s when connecting to server because %s",sql,e.getMessage()));
}
return 0;
}
@Override
public int executeUpdate(String arg0, int arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int executeUpdate(String arg0, int[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int executeUpdate(String arg0, String[] arg1) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public Connection getConnection() throws SQLException {
return connection;
}
@Override
public int getFetchDirection() throws SQLException {
checkConnection("getFetchDirection");
return ResultSet.FETCH_FORWARD;
}
@Override
public int getFetchSize() throws SQLException {
checkConnection("getFetchSize");
return fetchSize;
}
@Override
public ResultSet getGeneratedKeys() throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
}
@Override
public int getMaxFieldSize() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getMaxRows() throws SQLException {
checkConnection("getMaxRows");
return maxRows;
}
@Override
public boolean getMoreResults() throws SQLException {
return false;
}
@Override
public boolean getMoreResults(int arg0) throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
}
@Override
public int getQueryTimeout() throws SQLException {
return this.queryTimeout;
}
@Override
public ResultSet getResultSet() throws SQLException {
checkConnection("getResultSet");
return resultSet;
}
@Override
public int getResultSetConcurrency() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getResultSetHoldability() throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public int getResultSetType() throws SQLException {
checkConnection("getResultSetType");
return ResultSet.TYPE_FORWARD_ONLY;
}
@Override
public int getUpdateCount() throws SQLException {
return 0;
}
@Override
public SQLWarning getWarnings() throws SQLException {
return warningChain;
}
@Override
public boolean isCloseOnCompletion() throws SQLException {
return false;
}
@Override
public boolean isClosed() throws SQLException {
return isClosed;
}
@Override
public boolean isPoolable() throws SQLException {
return false;
}
@Override
public void setCursorName(String arg0) throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
}
@Override
public void setEscapeProcessing(boolean enable) throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported");
}
@Override
public void setFetchDirection(int direction) throws SQLException {
checkConnection("setFetchDirection");
if (direction != ResultSet.FETCH_FORWARD) {
throw new SQLException(String.format("direction %d is not supported!", direction));
}
}
@Override
public void setFetchSize(int fetchSize) throws SQLException {
checkConnection("setFetchSize");
if (fetchSize < 0) {
throw new SQLException(String.format("fetchSize %d must be >= 0!", fetchSize));
}
this.fetchSize = fetchSize == 0 ? TsfileConfig.DEFAULT_FETCH_SIZE : fetchSize;
}
@Override
public void setMaxFieldSize(int arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setMaxRows(int num) throws SQLException {
checkConnection("setMaxRows");
if (num < 0) {
throw new SQLException(String.format("maxRows %d must be >= 0!", num));
}
this.maxRows = num;
}
@Override
public void setPoolable(boolean arg0) throws SQLException {
throw new SQLException("Method not supported");
}
@Override
public void setQueryTimeout(int seconds) throws SQLException {
checkConnection("setQueryTimeout");
if (seconds <= 0) {
throw new SQLException(String.format("queryTimeout %d must be >= 0!", seconds));
}
this.queryTimeout = seconds;
}
private void checkConnection(String action) throws SQLException {
if (isClosed) {
throw new SQLException(String.format("Cannot %s after statement has been closed!", action));
}
}
}

View File

@ -0,0 +1,15 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.sql.SQLException;
public class TsfileURLException extends SQLException{
/**
*
*/
private static final long serialVersionUID = -5071922897222027267L;
public TsfileURLException(String reason){
super(reason);
}
}

View File

@ -0,0 +1,162 @@
package cn.edu.thu.tsfiledb.jdbc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.edu.thu.tsfile.common.utils.Binary;
import cn.edu.thu.tsfile.file.metadata.enums.TSDataType;
import cn.edu.thu.tsfile.file.metadata.enums.TSEncoding;
import cn.edu.thu.tsfile.timeseries.read.query.DynamicOneColumnData;
import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet;
import cn.edu.thu.tsfiledb.metadata.ColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSDynamicOneColumnData;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_Status;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode;
public class Utils {
/**
* Parse JDBC connection URL The only supported format of the URL is:
* jdbc:tsfile://localhost:8888/seriesName
*
* @param url
* @return
* @throws TsfileURLException
*/
public static TsfileConnectionParams parseURL(String url, Properties info) throws TsfileURLException {
TsfileConnectionParams params = new TsfileConnectionParams(url);
if(url.trim().equalsIgnoreCase(TsfileConfig.TSFILE_URL_PREFIX)){
return params;
}
Pattern pattern = Pattern.compile("([^;]*):([^;]*)/");
Matcher matcher = pattern.matcher(url.substring(TsfileConfig.TSFILE_URL_PREFIX.length()));
boolean isUrlLegal = false;
while(matcher.find()){
params.setHost(matcher.group(1));
params.setPort(Integer.parseInt((matcher.group(2))));
isUrlLegal = true;
}
if(!isUrlLegal){
throw new TsfileURLException("Error url format, url should be jdbc:tsfile://ip:port/");
}
if(info.containsKey(TsfileConfig.AUTH_USER)){
params.setUsername(info.getProperty(TsfileConfig.AUTH_USER));
}
if(info.containsKey(TsfileConfig.AUTH_PASSWORD)){
params.setPassword(info.getProperty(TsfileConfig.AUTH_PASSWORD));
}
return params;
}
public static void verifySuccess(TS_Status status) throws TsfileSQLException{
if(status.getStatusCode() != TS_StatusCode.SUCCESS_STATUS){
throw new TsfileSQLException(status.errorMessage);
}
}
public static Map<String, List<ColumnSchema>> convertAllSchema(Map<String, List<TSColumnSchema>> tsAllSchema){
if(tsAllSchema == null){
return null;
}
Map<String, List<ColumnSchema>> allSchema = new HashMap<>();
for(Map.Entry<String, List<TSColumnSchema>> entry : tsAllSchema.entrySet()){
List<ColumnSchema> columnSchemas = new ArrayList<>();
for(TSColumnSchema columnSchema : entry.getValue()){
columnSchemas.add(convertColumnSchema(columnSchema));
}
allSchema.put(entry.getKey(), columnSchemas);
}
return allSchema;
}
public static ColumnSchema convertColumnSchema(TSColumnSchema tsSchema){
if(tsSchema == null){
return null;
}
TSDataType dataType = tsSchema.dataType == null ? null : TSDataType.valueOf(tsSchema.dataType);
TSEncoding encoding = tsSchema.encoding == null ? null : TSEncoding.valueOf(tsSchema.encoding);
ColumnSchema ColumnSchema = new ColumnSchema(tsSchema.name, dataType, encoding);
ColumnSchema.setArgsMap(tsSchema.getOtherArgs());
return ColumnSchema;
}
public static QueryDataSet convertQueryDataSet(TSQueryDataSet tsQueryDataSet){
QueryDataSet queryDataSet = new QueryDataSet();
List<String> keys = tsQueryDataSet.getKeys();
List<TSDynamicOneColumnData> values = tsQueryDataSet.getValues();
LinkedHashMap<String, DynamicOneColumnData> ret = new LinkedHashMap<>();
int length = keys.size();
for(int i = 0; i < length;i++){
ret.put(keys.get(i), convertDynamicOneColumnData(values.get(i)));
}
queryDataSet.mapRet = ret;
return queryDataSet;
}
public static DynamicOneColumnData convertDynamicOneColumnData(TSDynamicOneColumnData tsDynamicOneColumnData){
TSDataType dataType = TSDataType.valueOf(tsDynamicOneColumnData.getDataType());
DynamicOneColumnData dynamicOneColumnData = new DynamicOneColumnData(dataType,true);
dynamicOneColumnData.setDeltaObjectType(tsDynamicOneColumnData.getDeviceType());
for(long time : tsDynamicOneColumnData.getTimeRet()){
dynamicOneColumnData.putTime(time);
}
switch (dataType) {
case BOOLEAN:
List<Boolean> booleans = tsDynamicOneColumnData.getBoolList();
for(Boolean b: booleans){
dynamicOneColumnData.putBoolean(b);
}
break;
case INT32:
List<Integer> integers = tsDynamicOneColumnData.getI32List();
for(Integer i: integers){
dynamicOneColumnData.putInt(i);
}
break;
case INT64:
List<Long> longs = tsDynamicOneColumnData.getI64List();
for(Long l: longs){
dynamicOneColumnData.putLong(l);
}
break;
case FLOAT:
List<Double> floats = tsDynamicOneColumnData.getFloatList();
for(double f: floats){
dynamicOneColumnData.putFloat((float)f);
}
break;
case DOUBLE:
List<Double> doubles = tsDynamicOneColumnData.getDoubleList();
for(double d: doubles){
dynamicOneColumnData.putDouble(d);
}
break;
case BYTE_ARRAY:
List<Byte> binaries = tsDynamicOneColumnData.getBinaryList();
for(Byte b: binaries){
dynamicOneColumnData.putBinary(new Binary(b.toString()));
}
break;
default:
break;
}
return dynamicOneColumnData;
}
}

View File

@ -0,0 +1,102 @@
package cn.edu.thu.tsfiledb.service;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.edu.thu.tsfile.timeseries.read.qp.Path;
import cn.edu.thu.tsfiledb.auth.dao.Authorizer;
import cn.edu.thu.tsfiledb.auth.model.Permission;
public class AuthorityChecker {
public static final String SUPER_USER = "root";
private static final Logger logger = LoggerFactory.getLogger(AuthorityChecker.class);
public static boolean check(String username, List<Path> paths, OperatorType type){
if(SUPER_USER.equals(username)){
return true;
}
int permission = translateToPermissionId(type);
if(permission == -1){
logger.error("OperateType not found. {}", type);
return false;
}
for(int i = 0 ; i < paths.size() ; i ++){
if(!checkOnePath(username, paths.get(i), permission)){
return false;
}
}
return true;
}
public static List<String> getAllParentPath(Path path){
List<String> parentPaths = new ArrayList<String>();
String fullPath = path.getFullPath();
String[] nodes = fullPath.split("\\.");
for(int i = 0 ; i < nodes.length ; i++){
StringBuilder sb = new StringBuilder();
for(int j = 0 ; j <= i ; j++){
sb.append(nodes[j]);
if(j < i){
sb.append(".");
}
}
parentPaths.add(sb.toString());
}
return parentPaths;
}
public static boolean checkOnePath(String username, Path path, int permission){
List<String> parentPaths = getAllParentPath(path);
for(int i = 0 ; i < parentPaths.size(); i ++){
if(Authorizer.checkUserPermission(username, parentPaths.get(i), permission)){
return true;
}
}
return false;
}
public static int translateToPermissionId(OperatorType type){
switch(type){
case METADATA:
return Permission.CREATE;
case QUERY:
case SELECT:
case FILTER:
case GROUPBY:
case SEQTABLESCAN:
case TABLESCAN:
return Permission.READ;
case DELETE:
return Permission.DELETE;
case INSERT:
case LOADDATA:
return Permission.INSERT;
case UPDATE:
return Permission.MODIFY;
case AUTHOR:
case BASIC_FUNC:
case FILEREAD:
case FROM:
case FUNC:
case HASHTABLESCAN:
case JOIN:
case LIMIT:
case MERGEJOIN:
case NULL:
case ORDERBY:
case PROPERTY:
case ROOT:
case UNION:
return -1;
default:
return -1;
}
}
}

View File

@ -0,0 +1,54 @@
package cn.edu.thu.tsfiledb.service;
import java.io.IOException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService.Processor;
public class Daemon {
public static void main(String[] args) {
//init Derby Database
DBdao dBdao = new DBdao();
dBdao.open();
startRPC();
}
public static TServer startRPC() {
try {
// 设置服务器端口
TServerSocket serverTransport = new TServerSocket(JDBCServerConfig.PORT);
// 设置二进制协议工厂
Factory protocolFactory = new TBinaryProtocol.Factory();
//处理器关联业务实现
Processor<TSIService.Iface> processor = new TSIService.Processor<TSIService.Iface>(new TSServiceImpl());
// 2. 使用线程池服务模型
TThreadPoolServer.Args poolArgs = new TThreadPoolServer.Args(serverTransport);
poolArgs.processor(processor);
poolArgs.protocolFactory(protocolFactory);
TServer poolServer = new TThreadPoolServer(poolArgs);
poolServer.serve();
} catch (TTransportException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,155 @@
package cn.edu.thu.tsfiledb.service;
import java.io.IOException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TBinaryProtocol.Factory;
import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.engine.exception.FileNodeManagerException;
import cn.edu.thu.tsfiledb.engine.exception.LRUManagerException;
import cn.edu.thu.tsfiledb.engine.filenode.FileNodeManager;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService.Processor;
public class JDBCServer implements JDBCServerMBean {
private static final Logger LOGGER = LoggerFactory.getLogger(JDBCServer.class);
private DBdao dBdao;
private Thread jdbcServerThread;
private boolean isStart;
private Factory protocolFactory;
private Processor<TSIService.Iface> processor;
private TServerSocket serverTransport;
private TThreadPoolServer.Args poolArgs;
private TServer poolServer;
private boolean isMerging;
public JDBCServer() throws TTransportException {
isStart = false;
isMerging = false;
}
@Override
public synchronized void startServer() {
if(isStart){
LOGGER.info("tsfile-service JDBCServer: jdbc server has been already running now");
return;
}
LOGGER.info("tsfile-service JDBCServer: starting jdbc server...");
dBdao = new DBdao();
dBdao.open();
try {
jdbcServerThread = new Thread(new JDBCServerThread());
} catch (IOException e) {
LOGGER.error("Server start Error. {}", e.getMessage());
e.printStackTrace();
return;
}
jdbcServerThread.start();
LOGGER.info("tsfile-service JDBCServer: start jdbc server successfully");
isStart = true;
}
@Override
public synchronized void restartServer() {
stopServer();
startServer();
}
@Override
public synchronized void stopServer() {
if(!isStart){
LOGGER.info("tsfile-service JDBCServer: jdbc server isn't running now");
return;
}
LOGGER.info("tsfile-service JDBCServer: closing jdbc server...");
if(dBdao != null){
dBdao.close();
dBdao = null;
}
LOGGER.info("tsfile-service JDBCServer: flush data in memory to disk");
try {
FileNodeManager.getInstance().close();
} catch (LRUManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
close();
LOGGER.info("tsfile-service JDBCServer: close jdbc server successfully");
}
private void close(){
if(poolServer != null){
poolServer.stop();
poolServer = null;
}
if(serverTransport != null){
serverTransport.close();
serverTransport = null;
}
isStart = false;
}
class JDBCServerThread implements Runnable{
public JDBCServerThread() throws IOException{
protocolFactory = new TBinaryProtocol.Factory();
processor = new TSIService.Processor<TSIService.Iface>(new TSServiceImpl());
}
@Override
public void run() {
try {
serverTransport = new TServerSocket(JDBCServerConfig.PORT);
poolArgs = new TThreadPoolServer.Args(serverTransport);
poolArgs.processor(processor);
poolArgs.protocolFactory(protocolFactory);
poolServer = new TThreadPoolServer(poolArgs);
// poolServer.serve(); will block next statement to execute
poolServer.serve();
} catch (TTransportException e) {
LOGGER.error("tsfile-service JDBCServer: failed to start jdbc server, because ", e);
} catch (Exception e) {
LOGGER.error("tsfile-service JDBCServer: jdbc server exit, because ", e);
} finally {
close();
LOGGER.info("tsfile-service JDBCServer: close TThreadPoolServer and TServerSocket");
}
}
}
public static void main(String[] args) throws TTransportException, InterruptedException{
JDBCServer server = new JDBCServer();
server.startServer();
}
@Override
public synchronized void mergeAll() {
LOGGER.info("tsfile-service JDBCServer : start merging..");
try {
FileNodeManager.getInstance().mergeAll();
} catch (FileNodeManagerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
LOGGER.info("tsfile-service JDBCServer : Done.");
}
}

View File

@ -0,0 +1,16 @@
package cn.edu.thu.tsfiledb.service;
public class JDBCServerConfig {
public static final int PORT = 6667;
// public static final String TSFILE_DATA_PATH = "writeV2Huge.out";
public static final String overflowErrOutput = "overflowErrOutput";
public static final String overflowOutput = "overflowOutput";
public static final String JMX_IP = "0.0.0.0";
public static final int JMX_PORT = 31999;
public static final String JMX_USER = "saf";
public static final String JMX_PASS = "pass";
}

View File

@ -0,0 +1,9 @@
package cn.edu.thu.tsfiledb.service;
public interface JDBCServerMBean {
public void startServer();
public void restartServer();
public void stopServer();
public void mergeAll();
}

View File

@ -0,0 +1,115 @@
package cn.edu.thu.tsfiledb.service;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.RMISocketFactory;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.remote.JMXAuthenticator;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXPrincipal;
import javax.management.remote.JMXServiceURL;
import javax.management.remote.rmi.RMIConnectorServer;
import javax.security.auth.Subject;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.core.joran.spi.JoranException;
import cn.edu.thu.tsfile.common.constant.SystemConstant;
public class JMXManager {
static{
try {
String home = System.getProperty(SystemConstant.TSFILE_HOME);
if(home != null && !home.equals("")){
LogBackConfigLoader.load(home + File.separator + "conf" + File.separator + "logback.xml");
}
} catch (IOException | JoranException e) {
System.out.println("Load configuration file error");
e.printStackTrace();
}
}
private static final Logger LOGGER = LoggerFactory.getLogger(JMXManager.class);
private JMXConnectorServer connector;
private Map<String, Object> jmxEnvironment;
public JMXManager() {
jmxEnvironment = new HashMap<String, Object>();
}
public void serice() throws IOException, TTransportException, MalformedObjectNameException,
InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
String addr = String.format("service:jmx:rmi://%s:%d/jndi/rmi://%s:%d/jmxrmi", JDBCServerConfig.JMX_IP,
JDBCServerConfig.JMX_PORT, JDBCServerConfig.JMX_IP, JDBCServerConfig.JMX_PORT);
JMXServiceURL address = new JMXServiceURL(addr);
RMISocketFactory rmiFactory = RMISocketFactory.getDefaultSocketFactory();
LocateRegistry.createRegistry(JDBCServerConfig.JMX_PORT, null, rmiFactory);
jmxEnvironment.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, rmiFactory);
// for auth
JMXAuthenticator auth = createJMXAuthenticator();
jmxEnvironment.put(JMXConnectorServer.AUTHENTICATOR, auth);
connector = JMXConnectorServerFactory.newJMXConnectorServer(address, jmxEnvironment,
ManagementFactory.getPlatformMBeanServer());
JDBCServerMBean mbean = new JDBCServer();
mbean.startServer();
ObjectName mBeanName = new ObjectName("JDBCServerDomain", "type", "JDBCServer");
mbs.registerMBean(mbean, mBeanName);
connector.start();
LOGGER.info("tsfile-service JMXManager: start JMX manager...");
}
public void close() throws IOException {
connector.stop();
LOGGER.info("tsfile-service JMXManager: close JMX manager...");
}
private JMXAuthenticator createJMXAuthenticator() {
return new JMXAuthenticator() {
public Subject authenticate(Object credentials) {
String[] sCredentials = (String[]) credentials;
if (null == sCredentials || sCredentials.length != 2) {
LOGGER.error("tsfile-service JMXManager: auth info in wrong format!");
throw new SecurityException("Authentication failed!");
}
String userName = sCredentials[0];
String pValue = sCredentials[1];
if (JDBCServerConfig.JMX_USER.equals(userName) && JDBCServerConfig.JMX_PASS.equals(pValue)) {
Set<JMXPrincipal> principals = new HashSet<JMXPrincipal>();
principals.add(new JMXPrincipal(userName));
return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
}
LOGGER.error("tsfile-service JMXManager: Authentication failed!");
throw new SecurityException("Authentication failed!");
}
};
}
public static void main(String[] args) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, TTransportException, IOException {
JMXManager manager = new JMXManager();
manager.serice();
}
}

View File

@ -0,0 +1,46 @@
package cn.edu.thu.tsfiledb.service;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.File;
import java.io.IOException;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;
/**
* Simple Utility class for loading an external config file for logback
* @author daniel
*/
public class LogBackConfigLoader {
public static void load (String externalConfigFileLocation) throws IOException, JoranException{
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
File externalConfigFile = new File(externalConfigFileLocation);
if(!externalConfigFile.exists()){
throw new IOException("Logback External Config File Parameter does not reference a file that exists");
}else{
if(!externalConfigFile.isFile()){
throw new IOException("Logback External Config File Parameter exists, but does not reference a file");
}else{
if(!externalConfigFile.canRead()){
throw new IOException("Logback External Config File exists and is a file, but cannot be read.");
}else{
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(externalConfigFileLocation);
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
}
}
}
}

View File

@ -0,0 +1,662 @@
package cn.edu.thu.tsfiledb.service;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.edu.thu.tsfile.common.exception.ProcessorException;
import cn.edu.thu.tsfile.file.metadata.enums.TSDataType;
import cn.edu.thu.tsfile.timeseries.read.qp.Path;
import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet;
import cn.edu.thu.tsfiledb.auth.dao.Authorizer;
import cn.edu.thu.tsfiledb.auth.model.AuthException;
import cn.edu.thu.tsfiledb.engine.filenode.FileNodeManager;
import cn.edu.thu.tsfiledb.exception.NotConsistentException;
import cn.edu.thu.tsfiledb.exception.PathErrorException;
import cn.edu.thu.tsfiledb.metadata.ColumnSchema;
import cn.edu.thu.tsfiledb.metadata.MManager;
import cn.edu.thu.tsfiledb.metadata.Metadata;
import cn.edu.thu.tsfiledb.query.aggregation.AggreFuncFactory;
import cn.edu.thu.tsfiledb.query.aggregation.AggregateFunction;
import cn.edu.thu.tsfiledb.query.engine.OverflowQueryEngine;
import cn.edu.thu.tsfiledb.query.management.ReadLockManager;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCancelOperationResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseOperationResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSCloseSessionResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteBatchStatementResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSExecuteStatementResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchMetadataResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSFetchResultsResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSHandleIdentifier;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionReq;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOpenSessionResp;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSOperationHandle;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_SessionHandle;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_Status;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSIService;;
public class TSServiceImpl implements TSIService.Iface {
private WriteLogManager writeLogManager;
private OverflowQPExecutor exec = new OverflowQPExecutor();
// Record the username for every rpc connection. Username.get() is null if
// login is failed.
private ThreadLocal<String> username = new ThreadLocal<>();
private ThreadLocal<HashMap<String, RootOperator>> queryStatus = new ThreadLocal<>();
private ThreadLocal<HashMap<String, Iterator<QueryDataSet>>> queryRet = new ThreadLocal<>();
private static final Logger LOGGER = LoggerFactory.getLogger(TSServiceImpl.class);
public TSServiceImpl() throws IOException {
LOGGER.info("start check write log...");
writeLogManager = WriteLogManager.getInstance();
long cnt = 0l;
PhysicalPlan plan;
while ((plan = writeLogManager.getPhysicalPlan()) != null) {
try {
plan.processNonQuery(exec);
cnt++;
} catch (ProcessorException e) {
e.printStackTrace();
throw new IOException("Error in recovery from write log");
}
}
LOGGER.info("Done. Recover operation count {}", cnt);
}
@Override
public TSOpenSessionResp OpenSession(TSOpenSessionReq req) throws TException {
if (LOGGER.isInfoEnabled())
LOGGER.info("tsfile-server TSServiceImpl: receive open session from username {}", req.getUsername());
boolean status = false;
try {
status = Authorizer.login(req.getUsername(), req.getPassword());
} catch (AuthException e) {
status = false;
}
// boolean status = true;
TS_Status ts_status;
if (status) {
ts_status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
ts_status.setErrorMessage("login successfully.");
username.set(req.getUsername());
initForOneSession();
} else {
ts_status = new TS_Status(TS_StatusCode.ERROR_STATUS);
ts_status.setErrorMessage("login failed. Username or password is wrong.");
}
TSOpenSessionResp resp = new TSOpenSessionResp(ts_status, TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1);
resp.setSessionHandle(new TS_SessionHandle(new TSHandleIdentifier(ByteBuffer.wrap(req.getUsername().getBytes()),
ByteBuffer.wrap((req.getPassword().getBytes())))));
if (LOGGER.isInfoEnabled())
LOGGER.info("tsfile-server TSServiceImpl: Login status: {}. User : {}", ts_status.getErrorMessage(),
req.getUsername());
return resp;
}
private void initForOneSession() {
queryStatus.set(new HashMap<String, RootOperator>());
queryRet.set(new HashMap<String, Iterator<QueryDataSet>>());
}
@Override
public TSCloseSessionResp CloseSession(TSCloseSessionReq req) throws TException {
if (LOGGER.isInfoEnabled())
LOGGER.info("tsfile-server TSServiceImpl: receive close session");
TS_Status ts_status;
if (username.get() == null) {
ts_status = new TS_Status(TS_StatusCode.ERROR_STATUS);
ts_status.setErrorMessage("Has not logged in");
} else {
ts_status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
username.remove();
}
return new TSCloseSessionResp(ts_status);
}
@Override
// TODO: 这个方法啥意思
public TSCancelOperationResp CancelOperation(TSCancelOperationReq req) throws TException {
if (LOGGER.isInfoEnabled())
LOGGER.info("tsfile-server TSServiceImpl: receive cancle operation");
return new TSCancelOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
}
@Override
public TSCloseOperationResp CloseOperation(TSCloseOperationReq req) throws TException {
if (LOGGER.isInfoEnabled())
LOGGER.info("tsfile-server TSServiceImpl: receive statement close operation");
try {
ReadLockManager.getInstance().unlockForOneRequest();
clearAllStatusForCurrentRequest();
} catch (NotConsistentException e) {
LOGGER.warn("Warning in closeOperation : {}", e.getMessage());
// e.printStackTrace();
} catch (ProcessorException e) {
// TODO Auto-generated catch block
LOGGER.error("Error in closeOperation : {}", e.getMessage());
e.printStackTrace();
}
return new TSCloseOperationResp(new TS_Status(TS_StatusCode.SUCCESS_STATUS));
}
public void clearAllStatusForCurrentRequest() {
this.queryRet.get().clear();
this.queryStatus.get().clear();
// Clear all parameters in last request.
exec.clearParamter();
}
@Override
public TSFetchMetadataResp FetchMetadata(TSFetchMetadataReq req) throws TException {
LOGGER.info("tsfile-server FetchMetadata: Receive fetch metadata operation");
TS_Status status;
if (!checkLogin()) {
LOGGER.info("tsfile-server ExecuteStatement: Not login.");
status = new TS_Status(TS_StatusCode.ERROR_STATUS);
status.setErrorMessage("Not login");
return new TSFetchMetadataResp(status);
}
TSFetchMetadataResp resp = new TSFetchMetadataResp();
try {
Metadata metadata = MManager.getInstance().getMetadata();
String metadataInJson = MManager.getInstance().getMetadataInString();
Map<String, List<ColumnSchema>> seriesMap = metadata.getSeriesMap();
Map<String, List<TSColumnSchema>> tsSeriesMap = Utils.convertAllSchema(seriesMap);
resp.setSeriesMap(tsSeriesMap);
resp.setDeltaObjectMap(metadata.getDeltaObjectMap());
resp.setMetadataInJson(metadataInJson);
status = new TS_Status(TS_StatusCode.SUCCESS_STATUS);
resp.setStatus(status);
} catch (PathErrorException e) {
LOGGER.error("tsfile-server FetchMetadata: failed to get all schema", e);
status = new TS_Status(TS_StatusCode.ERROR_STATUS);
status.setErrorMessage(e.getMessage());
resp.setStatus(status);
resp.setSeriesMap(null);
resp.setDeltaObjectMap(null);
resp.setMetadataInJson(null);
} catch (Exception e) {
LOGGER.error("tsfile-server FetchMetadata: failed to get all schema with unknown reason", e);
status = new TS_Status(TS_StatusCode.ERROR_STATUS);
status.setErrorMessage(e.getMessage());
resp.setStatus(status);
resp.setSeriesMap(null);
resp.setDeltaObjectMap(null);
resp.setMetadataInJson(null);
}
return resp;
}
/**
* Judge whether the statement is ADMIN COMMOND and if true, execute it.
*
* @param statement
* @return true if the statement is ADMIN COMMOND
* @throws IOException
*/
public boolean execAdminCommond(String statement) throws IOException {
if (!username.get().equals("root")) {
return false;
}
if (statement == null) {
return false;
}
statement = statement.toLowerCase();
switch (statement) {
case "close":
FileNodeManager.getInstance().closeAll();
writeLogManager.overflowFlush();
writeLogManager.bufferFlush();
// MManager.getInstance().flushObjectToFile();
return true;
case "merge":
FileNodeManager.getInstance().mergeAll();
return true;
}
return false;
}
/**
* 用来测试的函数,仅供测试后面要删除
*
* @param req
* @return
* @throws TException
*/
public TSExecuteStatementResp testExecute(TSExecuteStatementReq req) {
TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "");
String sql = req.statement;
String[] params = sql.substring(5).split(" ");
List<String> columns = new ArrayList<>();
columns.add(params[0] + "(" + params[1] + ")");
TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap(("PASS".getBytes())));
TSOperationHandle operationHandle = null;
resp.setColumns(columns);
operationHandle = new TSOperationHandle(operationId, true);
resp.setOperationHandle(operationHandle);
recordANewQuery(sql, null);
return resp;
}
@Override
public TSExecuteBatchStatementResp ExecuteBatchStatement(TSExecuteBatchStatementReq req) throws TException {
try {
LOGGER.info("tsfile-server ExecuteBatchStatement: Receive execute batch sql operation");
if (!checkLogin()) {
LOGGER.info("tsfile-server ExecuteBatchStatement: Not login.");
return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login", null);
}
List<String> statements = req.getStatements();
List<Integer> result = new ArrayList<>();
TSqlParserV2 parser = new TSqlParserV2();
ArrayList<RootOperator> opList = new ArrayList<>();
for (String statement : statements) {
RootOperator root = parser.parseSQLToOperator(statement);
if (root.isQuery()) {
return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
"statement is query :" + statement, result);
}
opList.add(root);
}
for (RootOperator op: opList) {
ExecuteUpdateStatement(op);
}
// TODO Auto-generated method stub
return getTSBathcExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "Execute statements successfully",
result);
} catch (Exception e) {
LOGGER.error("tsfile-server ExecuteBatchStatement: error occurs when executing statements", e);
return getTSBathcExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage(), null);
}
}
@Override
public TSExecuteStatementResp ExecuteStatement(TSExecuteStatementReq req) throws TException {
try {
// 测试代码
String sql = req.getStatement();
if (sql != null && sql.startsWith("test:")) {
return testExecute(req);
}
// 测试代码结束
LOGGER.info("tsfile-server ExecuteStatement: Receive execute sql operation,statement {}", req.statement);
if (!checkLogin()) {
LOGGER.info("tsfile-server ExecuteStatement: Not login.");
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login");
}
String statement = req.getStatement();
try {
if (execAdminCommond(statement)) {
return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "ADMIN_COMMOND_SUCCESS");
}
} catch (Exception e) {
e.printStackTrace();
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Server Internal Error");
}
TSqlParserV2 parser = new TSqlParserV2();
RootOperator root;
try {
root = parser.parseSQLToOperator(statement);
} catch (IllegalASTFormatException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS,
"Statement is not right:" + e.getMessage());
} catch (NullPointerException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement is not allowed");
}
if (root.isQuery()) {
return ExecuteQueryStatement(req);
} else {
return ExecuteUpdateStatement(root);
}
} catch (Exception e) {
e.printStackTrace();
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
}
@Override
public TSExecuteStatementResp ExecuteQueryStatement(TSExecuteStatementReq req) throws TException {
try {
LOGGER.info("tsfile-server ExecuteQueryStatement: receive query sql operation,statement {}", req.statement);
if (!checkLogin()) {
LOGGER.info("tsfile-server ExecuteQueryStatement: Not login.");
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login");
}
String statement = req.getStatement();
TSqlParserV2 parser = new TSqlParserV2();
RootOperator root = parser.parseSQLToOperator(statement);
List<Path> paths = null;
// paths = ((SFWOperator) root).getSelSeriesPaths(exec);
PhysicalPlan plan = parser.parseSQLToPhysicalPlan(statement, exec);
paths = plan.getInvolvedSeriesPaths();
// check whether current statement is a query statement
if (!root.isQuery()) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement Error: Not a query statement");
}
// check path exists
if (paths.size() == 0) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Selected columns do NOT EXIST.");
}
// check file level set
try {
MManager.getInstance().checkFileLevel(paths);
} catch (PathErrorException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
// check permissions
if (!checkAuthorization(paths, root.getType())) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this query.");
}
TSExecuteStatementResp resp = getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "");
List<String> columns = new ArrayList<>();
for (Path p : paths) {
columns.add(p.getFullPath());
}
TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap(("PASS".getBytes())));
TSOperationHandle operationHandle = null;
resp.setColumns(columns);
operationHandle = new TSOperationHandle(operationId, true);
resp.setOperationHandle(operationHandle);
recordANewQuery(statement, root);
LOGGER.info("ExecuteQueryStatement: finish query statement {}", statement);
return resp;
} catch (Exception e) {
LOGGER.error("Server internal error: {}", e.getMessage());
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
}
public TSFetchResultsResp testFetchResults(TSFetchResultsReq req) {
String sql = req.statement;
if (!queryStatus.get().containsKey(sql)) {
TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS,
"FetchResult successfully. Has more result: " + false);
resp.setHasResultSet(false);
return resp;
}
String[] params = sql.substring(5).split(" ");
TSDataType dataType;
try {
dataType = MManager.getInstance().getSeriesType(params[1]);
AggregateFunction aggrFunc = AggreFuncFactory.getAggrFuncByName(params[0], dataType);
Path p = new Path(params[1]);
QueryDataSet queryDataSet = new OverflowQueryEngine().aggregate(p, aggrFunc, null, null, null);
TSQueryDataSet tsQueryDataSet = Utils.convertQueryDataSet(queryDataSet);
TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS,
"FetchResult successfully. Has more result: " + false);
resp.setHasResultSet(true);
resp.setQueryDataSet(tsQueryDataSet);
queryStatus.get().remove(sql);
return resp;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@Override
public TSFetchResultsResp FetchResults(TSFetchResultsReq req) throws TException {
// 测试代码
if (req.statement.startsWith("test:")) {
return testFetchResults(req);
}
// 测试代码结束
try {
if (!checkLogin()) {
return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Not login.");
}
String statement = req.getStatement();
LOGGER.info("tsfile-server TSServiceImpl: receive fetch result sql operation,statement {}", statement);
if (!queryStatus.get().containsKey(statement)) {
return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Has not executed statement");
}
int fetchSize = req.getFetch_size();
Iterator<QueryDataSet> queryDataSetIterator;
if (!queryRet.get().containsKey(statement)) {
TSqlParserV2 parser = new TSqlParserV2();
RootOperator operator = queryStatus.get().get(statement);
exec.setFetchSize(fetchSize);
queryDataSetIterator = parser.query(operator, exec);
queryRet.get().put(statement, queryDataSetIterator);
} else {
queryDataSetIterator = queryRet.get().get(statement);
}
boolean hasResultSet = false;
// TODO: 需要和徐毅确认res是否可以这么用
QueryDataSet res = new QueryDataSet();
if (queryDataSetIterator.hasNext()) {
res = queryDataSetIterator.next();
hasResultSet = true;
} else {
hasResultSet = false;
queryRet.get().remove(statement);
}
TSQueryDataSet tsQueryDataSet = Utils.convertQueryDataSet(res);
TSFetchResultsResp resp = getTSFetchResultsResp(TS_StatusCode.SUCCESS_STATUS,
"FetchResult successfully. Has more result: " + hasResultSet);
resp.setHasResultSet(hasResultSet);
resp.setQueryDataSet(tsQueryDataSet);
return resp;
} catch (Exception e) {
LOGGER.error("Server Internal Error: {}", e.getMessage());
e.printStackTrace();
return getTSFetchResultsResp(TS_StatusCode.ERROR_STATUS, "Server Internal Error");
}
}
@Override
public TSExecuteStatementResp ExecuteUpdateStatement(TSExecuteStatementReq req) throws TException {
try {
if (!checkLogin()) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Not login");
}
String statement = req.getStatement();
return ExecuteUpdateStatement(statement);
} catch (ProcessorException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
} catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage());
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
}
private TSExecuteStatementResp ExecuteUpdateStatement(RootOperator root) throws TException {
try {
LOGGER.debug("ExecuteUpdateStatement: receive statement {}", root);
PhysicalPlan plan = root.transformToPhysicalPlan(exec);
List<Path> paths = plan.getInvolvedSeriesPaths();
if (!checkAuthorization(paths, root.getType())) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this operation");
}
// TODO 是否要添加执行的信息而不是仅仅返回正确或者错误
boolean execRet;
try {
execRet = plan.processNonQuery(exec);
} catch (ProcessorException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
if (execRet && needToBeWritenToLog(plan)) {
writeLogManager.write(plan);
}
TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS;
String msg = execRet ? "Execute successfully" : "Execute statement error.";
TSExecuteStatementResp resp = getTSExecuteStatementResp(statusCode, msg);
TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap(("PASS".getBytes())));
TSOperationHandle operationHandle = null;
operationHandle = new TSOperationHandle(operationId, false);
resp.setOperationHandle(operationHandle);
return resp;
} catch (QueryProcessorException e) {
LOGGER.error(e.getMessage());
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
} catch (IOException e) {
LOGGER.error("Write preLog error", e);
return getTSExecuteStatementResp(TS_StatusCode.SUCCESS_STATUS, "Write log error");
}
}
private TSExecuteStatementResp ExecuteUpdateStatement(String statement)
throws TException, QueryProcessorException, IOException, ProcessorException {
LOGGER.info("ExecuteUpdateStatement: receive statement {}", statement);
TSqlParserV2 parser = new TSqlParserV2();
RootOperator root;
try {
root = parser.parseSQLToOperator(statement);
} catch (QueryProcessorException e) {
e.printStackTrace();
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
if (root.isQuery()) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "Statement is a query statement.");
}
// 如果操作是增删改
PhysicalPlan plan = parser.parseSQLToPhysicalPlan(statement, exec);
List<Path> paths = plan.getInvolvedSeriesPaths();
if (!checkAuthorization(paths, root.getType())) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, "No permissions for this operation");
}
// TODO 是否要添加执行的信息而不是仅仅返回正确或者错误
boolean execRet;
try {
execRet = parser.nonQuery(root, exec);
} catch (ProcessorException e) {
return getTSExecuteStatementResp(TS_StatusCode.ERROR_STATUS, e.getMessage());
}
if (execRet && needToBeWritenToLog(plan)) {
writeLogManager.write(plan);
}
TS_StatusCode statusCode = execRet ? TS_StatusCode.SUCCESS_STATUS : TS_StatusCode.ERROR_STATUS;
String msg = execRet ? "Execute successfully" : "Execute statement error.";
TSExecuteStatementResp resp = getTSExecuteStatementResp(statusCode, msg);
TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap(("PASS".getBytes())));
TSOperationHandle operationHandle = null;
operationHandle = new TSOperationHandle(operationId, false);
resp.setOperationHandle(operationHandle);
return resp;
}
private boolean needToBeWritenToLog(PhysicalPlan plan) {
if (plan.getOperatorType() == OperatorType.INSERT) {
return true;
}
if (plan.getOperatorType() == OperatorType.UPDATE) {
return true;
}
if (plan.getOperatorType() == OperatorType.DELETE) {
return true;
}
return false;
}
private void recordANewQuery(String statement, RootOperator op) {
queryStatus.get().put(statement, op);
// refresh current queryRet for statement
if (queryRet.get().containsKey(statement)) {
queryRet.get().remove(statement);
}
}
/**
* Check whether current user has logined.
*
* @return true: If logined; false: If not logined
*/
private boolean checkLogin() {
if (username.get() == null) {
return false;
}
return true;
}
private boolean checkAuthorization(List<Path> paths, OperatorType type) {
return AuthorityChecker.check(username.get(), paths, type);
}
private TSExecuteStatementResp getTSExecuteStatementResp(TS_StatusCode code, String msg) {
TSExecuteStatementResp resp = new TSExecuteStatementResp();
TS_Status ts_status = new TS_Status(code);
ts_status.setErrorMessage(msg);
resp.setStatus(ts_status);
TSHandleIdentifier operationId = new TSHandleIdentifier(ByteBuffer.wrap(username.get().getBytes()),
ByteBuffer.wrap(("PASS".getBytes())));
TSOperationHandle operationHandle = new TSOperationHandle(operationId, false);
resp.setOperationHandle(operationHandle);
return resp;
}
private TSExecuteBatchStatementResp getTSBathcExecuteStatementResp(TS_StatusCode code, String msg,
List<Integer> result) {
TSExecuteBatchStatementResp resp = new TSExecuteBatchStatementResp();
TS_Status ts_status = new TS_Status(code);
ts_status.setErrorMessage(msg);
resp.setStatus(ts_status);
resp.setResult(result);
return resp;
}
private TSFetchResultsResp getTSFetchResultsResp(TS_StatusCode code, String msg) {
TSFetchResultsResp resp = new TSFetchResultsResp();
TS_Status ts_status = new TS_Status(code);
ts_status.setErrorMessage(msg);
resp.setStatus(ts_status);
return resp;
}
}

View File

@ -0,0 +1,129 @@
package cn.edu.thu.tsfiledb.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.edu.thu.tsfile.timeseries.read.query.DynamicOneColumnData;
import cn.edu.thu.tsfile.timeseries.read.query.QueryDataSet;
import cn.edu.thu.tsfiledb.metadata.ColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSColumnSchema;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSDynamicOneColumnData;
import cn.edu.thu.tsfiledb.service.rpc.thrift.TSQueryDataSet;
public class Utils {
public static Map<String, List<TSColumnSchema>> convertAllSchema(Map<String, List<ColumnSchema>> allSchema){
if(allSchema == null){
return null;
}
Map<String, List<TSColumnSchema>> tsAllSchema = new HashMap<>();
for(Map.Entry<String, List<ColumnSchema>> entry : allSchema.entrySet()){
List<TSColumnSchema> tsColumnSchemas = new ArrayList<>();
for(ColumnSchema columnSchema : entry.getValue()){
tsColumnSchemas.add(convertColumnSchema(columnSchema));
}
tsAllSchema.put(entry.getKey(), tsColumnSchemas);
}
return tsAllSchema;
}
public static TSColumnSchema convertColumnSchema(ColumnSchema schema){
if(schema == null){
return null;
}
TSColumnSchema tsColumnSchema = new TSColumnSchema();
tsColumnSchema.setName(schema.name);
tsColumnSchema.setDataType(schema.dataType == null ? null : schema.dataType.toString());
tsColumnSchema.setEncoding(schema.encoding == null ? null : schema.encoding.toString());
tsColumnSchema.setOtherArgs(schema.getArgsMap() == null ? null : schema.getArgsMap());
return tsColumnSchema;
}
public static TSQueryDataSet convertQueryDataSet(QueryDataSet queryDataSet){
List<String> keys = new ArrayList<>();
List<TSDynamicOneColumnData> values = new ArrayList<>();
for(Map.Entry<String,DynamicOneColumnData> entry: queryDataSet.mapRet.entrySet()){
keys.add(entry.getKey());
values.add(convertDynamicOneColumnData(entry.getValue()));
}
TSQueryDataSet tsQueryDataSet = new TSQueryDataSet(keys,values);
return tsQueryDataSet;
}
public static TSDynamicOneColumnData convertDynamicOneColumnData(DynamicOneColumnData dynamicOneColumnData){
List<Long> timeRetList = new ArrayList<Long>();
for(int i = 0 ; i < dynamicOneColumnData.timeLength; i ++){
timeRetList.add(dynamicOneColumnData.getTime(i));
}
TSDynamicOneColumnData tsDynamicOneColumnData = new TSDynamicOneColumnData(dynamicOneColumnData.getDeltaObjectType(), dynamicOneColumnData.dataType.toString(), dynamicOneColumnData.length, timeRetList);
switch (dynamicOneColumnData.dataType) {
case BOOLEAN:
List<Boolean> boolList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
boolList.add(dynamicOneColumnData.getBoolean(i));
}
tsDynamicOneColumnData.setBoolList(boolList);
break;
case INT32:
List<Integer> intList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
intList.add(dynamicOneColumnData.getInt(i));
}
tsDynamicOneColumnData.setI32List(intList);
break;
case INT64:
List<Long> longList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
longList.add(dynamicOneColumnData.getLong(i));
}
tsDynamicOneColumnData.setI64List(longList);
break;
case FLOAT:
List<Double> floatList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
floatList.add((double) dynamicOneColumnData.getFloat(i));
}
tsDynamicOneColumnData.setFloatList(floatList);
break;
case DOUBLE:
List<Double> doubleList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
doubleList.add(dynamicOneColumnData.getDouble(i));
}
tsDynamicOneColumnData.setDoubleList(doubleList);
break;
case BYTE_ARRAY:
List<Byte> byteList = new ArrayList<>();
for(int i = 0 ; i < dynamicOneColumnData.length; i ++){
byteList.add(Byte.valueOf(dynamicOneColumnData.getStringValue(i)));
}
tsDynamicOneColumnData.setBinaryList(byteList);
break;
default:
break;
}
return tsDynamicOneColumnData;
}
// public static TSJDBCRecord convertRecord(TSRecord record){
// TSJDBCRecord tsJDBCRecord = new TSJDBCRecord();
// tsJDBCRecord.setDeviceId(record.getRowKey());
// tsJDBCRecord.setTimeValue(new TSTimeValue(record.getTime().getTime()));
// tsJDBCRecord.setDeviceType(record.getDeviceType());
// List<TSDataPoint> dataPoints = new ArrayList<>();
// for(DataPoint point : record.getTuple()){
// String valueStr = point.getValue() == null ? "null" : point.getValue();
// TSDataPoint tsDataPoint = new TSDataPoint(point.getType().toString(),point.getSeriesName(),point.getDeviceId(),valueStr);
// tsDataPoint.setGroupId(point.getGroupId());
// dataPoints.add(tsDataPoint);
// }
// tsJDBCRecord.setDataList(dataPoints);
// return tsJDBCRecord;
// }
}

View File

@ -0,0 +1,393 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCancelOperationReq implements org.apache.thrift.TBase<TSCancelOperationReq, TSCancelOperationReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSCancelOperationReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCancelOperationReq");
private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCancelOperationReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCancelOperationReqTupleSchemeFactory());
}
public TSOperationHandle operationHandle; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
OPERATION_HANDLE((short)1, "operationHandle");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // OPERATION_HANDLE
return OPERATION_HANDLE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCancelOperationReq.class, metaDataMap);
}
public TSCancelOperationReq() {
}
public TSCancelOperationReq(
TSOperationHandle operationHandle)
{
this();
this.operationHandle = operationHandle;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCancelOperationReq(TSCancelOperationReq other) {
if (other.isSetOperationHandle()) {
this.operationHandle = other.operationHandle;
}
}
public TSCancelOperationReq deepCopy() {
return new TSCancelOperationReq(this);
}
@Override
public void clear() {
this.operationHandle = null;
}
public TSOperationHandle getOperationHandle() {
return this.operationHandle;
}
public TSCancelOperationReq setOperationHandle(TSOperationHandle operationHandle) {
this.operationHandle = operationHandle;
return this;
}
public void unsetOperationHandle() {
this.operationHandle = null;
}
/** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */
public boolean isSetOperationHandle() {
return this.operationHandle != null;
}
public void setOperationHandleIsSet(boolean value) {
if (!value) {
this.operationHandle = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case OPERATION_HANDLE:
if (value == null) {
unsetOperationHandle();
} else {
setOperationHandle((TSOperationHandle)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case OPERATION_HANDLE:
return getOperationHandle();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OPERATION_HANDLE:
return isSetOperationHandle();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCancelOperationReq)
return this.equals((TSCancelOperationReq)that);
return false;
}
public boolean equals(TSCancelOperationReq that) {
if (that == null)
return false;
boolean this_present_operationHandle = true && this.isSetOperationHandle();
boolean that_present_operationHandle = true && that.isSetOperationHandle();
if (this_present_operationHandle || that_present_operationHandle) {
if (!(this_present_operationHandle && that_present_operationHandle))
return false;
if (!this.operationHandle.equals(that.operationHandle))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_operationHandle = true && (isSetOperationHandle());
list.add(present_operationHandle);
if (present_operationHandle)
list.add(operationHandle);
return list.hashCode();
}
@Override
public int compareTo(TSCancelOperationReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOperationHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCancelOperationReq(");
boolean first = true;
sb.append("operationHandle:");
if (this.operationHandle == null) {
sb.append("null");
} else {
sb.append(this.operationHandle);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (operationHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCancelOperationReqStandardSchemeFactory implements SchemeFactory {
public TSCancelOperationReqStandardScheme getScheme() {
return new TSCancelOperationReqStandardScheme();
}
}
private static class TSCancelOperationReqStandardScheme extends StandardScheme<TSCancelOperationReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCancelOperationReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // OPERATION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCancelOperationReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.operationHandle != null) {
oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC);
struct.operationHandle.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCancelOperationReqTupleSchemeFactory implements SchemeFactory {
public TSCancelOperationReqTupleScheme getScheme() {
return new TSCancelOperationReqTupleScheme();
}
}
private static class TSCancelOperationReqTupleScheme extends TupleScheme<TSCancelOperationReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.operationHandle.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
}
}
}

View File

@ -0,0 +1,396 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCancelOperationResp implements org.apache.thrift.TBase<TSCancelOperationResp, TSCancelOperationResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSCancelOperationResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCancelOperationResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCancelOperationRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCancelOperationRespTupleSchemeFactory());
}
public TS_Status status; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCancelOperationResp.class, metaDataMap);
}
public TSCancelOperationResp() {
}
public TSCancelOperationResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCancelOperationResp(TSCancelOperationResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
}
public TSCancelOperationResp deepCopy() {
return new TSCancelOperationResp(this);
}
@Override
public void clear() {
this.status = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSCancelOperationResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCancelOperationResp)
return this.equals((TSCancelOperationResp)that);
return false;
}
public boolean equals(TSCancelOperationResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
return list.hashCode();
}
@Override
public int compareTo(TSCancelOperationResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCancelOperationResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCancelOperationRespStandardSchemeFactory implements SchemeFactory {
public TSCancelOperationRespStandardScheme getScheme() {
return new TSCancelOperationRespStandardScheme();
}
}
private static class TSCancelOperationRespStandardScheme extends StandardScheme<TSCancelOperationResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCancelOperationResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCancelOperationResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCancelOperationRespTupleSchemeFactory implements SchemeFactory {
public TSCancelOperationRespTupleScheme getScheme() {
return new TSCancelOperationRespTupleScheme();
}
}
private static class TSCancelOperationRespTupleScheme extends TupleScheme<TSCancelOperationResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCancelOperationResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
}
}
}

View File

@ -0,0 +1,393 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCloseOperationReq implements org.apache.thrift.TBase<TSCloseOperationReq, TSCloseOperationReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSCloseOperationReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseOperationReq");
private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCloseOperationReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCloseOperationReqTupleSchemeFactory());
}
public TSOperationHandle operationHandle; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
OPERATION_HANDLE((short)1, "operationHandle");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // OPERATION_HANDLE
return OPERATION_HANDLE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseOperationReq.class, metaDataMap);
}
public TSCloseOperationReq() {
}
public TSCloseOperationReq(
TSOperationHandle operationHandle)
{
this();
this.operationHandle = operationHandle;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCloseOperationReq(TSCloseOperationReq other) {
if (other.isSetOperationHandle()) {
this.operationHandle = other.operationHandle;
}
}
public TSCloseOperationReq deepCopy() {
return new TSCloseOperationReq(this);
}
@Override
public void clear() {
this.operationHandle = null;
}
public TSOperationHandle getOperationHandle() {
return this.operationHandle;
}
public TSCloseOperationReq setOperationHandle(TSOperationHandle operationHandle) {
this.operationHandle = operationHandle;
return this;
}
public void unsetOperationHandle() {
this.operationHandle = null;
}
/** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */
public boolean isSetOperationHandle() {
return this.operationHandle != null;
}
public void setOperationHandleIsSet(boolean value) {
if (!value) {
this.operationHandle = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case OPERATION_HANDLE:
if (value == null) {
unsetOperationHandle();
} else {
setOperationHandle((TSOperationHandle)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case OPERATION_HANDLE:
return getOperationHandle();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OPERATION_HANDLE:
return isSetOperationHandle();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCloseOperationReq)
return this.equals((TSCloseOperationReq)that);
return false;
}
public boolean equals(TSCloseOperationReq that) {
if (that == null)
return false;
boolean this_present_operationHandle = true && this.isSetOperationHandle();
boolean that_present_operationHandle = true && that.isSetOperationHandle();
if (this_present_operationHandle || that_present_operationHandle) {
if (!(this_present_operationHandle && that_present_operationHandle))
return false;
if (!this.operationHandle.equals(that.operationHandle))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_operationHandle = true && (isSetOperationHandle());
list.add(present_operationHandle);
if (present_operationHandle)
list.add(operationHandle);
return list.hashCode();
}
@Override
public int compareTo(TSCloseOperationReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOperationHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCloseOperationReq(");
boolean first = true;
sb.append("operationHandle:");
if (this.operationHandle == null) {
sb.append("null");
} else {
sb.append(this.operationHandle);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (operationHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCloseOperationReqStandardSchemeFactory implements SchemeFactory {
public TSCloseOperationReqStandardScheme getScheme() {
return new TSCloseOperationReqStandardScheme();
}
}
private static class TSCloseOperationReqStandardScheme extends StandardScheme<TSCloseOperationReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseOperationReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // OPERATION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseOperationReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.operationHandle != null) {
oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC);
struct.operationHandle.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCloseOperationReqTupleSchemeFactory implements SchemeFactory {
public TSCloseOperationReqTupleScheme getScheme() {
return new TSCloseOperationReqTupleScheme();
}
}
private static class TSCloseOperationReqTupleScheme extends TupleScheme<TSCloseOperationReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.operationHandle.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
}
}
}

View File

@ -0,0 +1,396 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCloseOperationResp implements org.apache.thrift.TBase<TSCloseOperationResp, TSCloseOperationResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSCloseOperationResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseOperationResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCloseOperationRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCloseOperationRespTupleSchemeFactory());
}
public TS_Status status; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseOperationResp.class, metaDataMap);
}
public TSCloseOperationResp() {
}
public TSCloseOperationResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCloseOperationResp(TSCloseOperationResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
}
public TSCloseOperationResp deepCopy() {
return new TSCloseOperationResp(this);
}
@Override
public void clear() {
this.status = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSCloseOperationResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCloseOperationResp)
return this.equals((TSCloseOperationResp)that);
return false;
}
public boolean equals(TSCloseOperationResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
return list.hashCode();
}
@Override
public int compareTo(TSCloseOperationResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCloseOperationResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCloseOperationRespStandardSchemeFactory implements SchemeFactory {
public TSCloseOperationRespStandardScheme getScheme() {
return new TSCloseOperationRespStandardScheme();
}
}
private static class TSCloseOperationRespStandardScheme extends StandardScheme<TSCloseOperationResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseOperationResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseOperationResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCloseOperationRespTupleSchemeFactory implements SchemeFactory {
public TSCloseOperationRespTupleScheme getScheme() {
return new TSCloseOperationRespTupleScheme();
}
}
private static class TSCloseOperationRespTupleScheme extends TupleScheme<TSCloseOperationResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseOperationResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
}
}
}

View File

@ -0,0 +1,393 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCloseSessionReq implements org.apache.thrift.TBase<TSCloseSessionReq, TSCloseSessionReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSCloseSessionReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseSessionReq");
private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCloseSessionReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCloseSessionReqTupleSchemeFactory());
}
public TS_SessionHandle sessionHandle; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
SESSION_HANDLE((short)1, "sessionHandle");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // SESSION_HANDLE
return SESSION_HANDLE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_SessionHandle")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseSessionReq.class, metaDataMap);
}
public TSCloseSessionReq() {
}
public TSCloseSessionReq(
TS_SessionHandle sessionHandle)
{
this();
this.sessionHandle = sessionHandle;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCloseSessionReq(TSCloseSessionReq other) {
if (other.isSetSessionHandle()) {
this.sessionHandle = other.sessionHandle;
}
}
public TSCloseSessionReq deepCopy() {
return new TSCloseSessionReq(this);
}
@Override
public void clear() {
this.sessionHandle = null;
}
public TS_SessionHandle getSessionHandle() {
return this.sessionHandle;
}
public TSCloseSessionReq setSessionHandle(TS_SessionHandle sessionHandle) {
this.sessionHandle = sessionHandle;
return this;
}
public void unsetSessionHandle() {
this.sessionHandle = null;
}
/** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */
public boolean isSetSessionHandle() {
return this.sessionHandle != null;
}
public void setSessionHandleIsSet(boolean value) {
if (!value) {
this.sessionHandle = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SESSION_HANDLE:
if (value == null) {
unsetSessionHandle();
} else {
setSessionHandle((TS_SessionHandle)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SESSION_HANDLE:
return getSessionHandle();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_HANDLE:
return isSetSessionHandle();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCloseSessionReq)
return this.equals((TSCloseSessionReq)that);
return false;
}
public boolean equals(TSCloseSessionReq that) {
if (that == null)
return false;
boolean this_present_sessionHandle = true && this.isSetSessionHandle();
boolean that_present_sessionHandle = true && that.isSetSessionHandle();
if (this_present_sessionHandle || that_present_sessionHandle) {
if (!(this_present_sessionHandle && that_present_sessionHandle))
return false;
if (!this.sessionHandle.equals(that.sessionHandle))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_sessionHandle = true && (isSetSessionHandle());
list.add(present_sessionHandle);
if (present_sessionHandle)
list.add(sessionHandle);
return list.hashCode();
}
@Override
public int compareTo(TSCloseSessionReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSessionHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCloseSessionReq(");
boolean first = true;
sb.append("sessionHandle:");
if (this.sessionHandle == null) {
sb.append("null");
} else {
sb.append(this.sessionHandle);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (sessionHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCloseSessionReqStandardSchemeFactory implements SchemeFactory {
public TSCloseSessionReqStandardScheme getScheme() {
return new TSCloseSessionReqStandardScheme();
}
}
private static class TSCloseSessionReqStandardScheme extends StandardScheme<TSCloseSessionReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseSessionReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // SESSION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseSessionReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.sessionHandle != null) {
oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC);
struct.sessionHandle.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCloseSessionReqTupleSchemeFactory implements SchemeFactory {
public TSCloseSessionReqTupleScheme getScheme() {
return new TSCloseSessionReqTupleScheme();
}
}
private static class TSCloseSessionReqTupleScheme extends TupleScheme<TSCloseSessionReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.sessionHandle.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
}
}
}

View File

@ -0,0 +1,396 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSCloseSessionResp implements org.apache.thrift.TBase<TSCloseSessionResp, TSCloseSessionResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSCloseSessionResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSCloseSessionResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSCloseSessionRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSCloseSessionRespTupleSchemeFactory());
}
public TS_Status status; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSCloseSessionResp.class, metaDataMap);
}
public TSCloseSessionResp() {
}
public TSCloseSessionResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSCloseSessionResp(TSCloseSessionResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
}
public TSCloseSessionResp deepCopy() {
return new TSCloseSessionResp(this);
}
@Override
public void clear() {
this.status = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSCloseSessionResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSCloseSessionResp)
return this.equals((TSCloseSessionResp)that);
return false;
}
public boolean equals(TSCloseSessionResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
return list.hashCode();
}
@Override
public int compareTo(TSCloseSessionResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSCloseSessionResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSCloseSessionRespStandardSchemeFactory implements SchemeFactory {
public TSCloseSessionRespStandardScheme getScheme() {
return new TSCloseSessionRespStandardScheme();
}
}
private static class TSCloseSessionRespStandardScheme extends StandardScheme<TSCloseSessionResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSCloseSessionResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSCloseSessionResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSCloseSessionRespTupleSchemeFactory implements SchemeFactory {
public TSCloseSessionRespTupleScheme getScheme() {
return new TSCloseSessionRespTupleScheme();
}
}
private static class TSCloseSessionRespTupleScheme extends TupleScheme<TSCloseSessionResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSCloseSessionResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
}
}
}

View File

@ -0,0 +1,769 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSColumnSchema implements org.apache.thrift.TBase<TSColumnSchema, TSColumnSchema._Fields>, java.io.Serializable, Cloneable, Comparable<TSColumnSchema> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSColumnSchema");
private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField DATA_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("dataType", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField ENCODING_FIELD_DESC = new org.apache.thrift.protocol.TField("encoding", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField OTHER_ARGS_FIELD_DESC = new org.apache.thrift.protocol.TField("otherArgs", org.apache.thrift.protocol.TType.MAP, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSColumnSchemaStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSColumnSchemaTupleSchemeFactory());
}
public String name; // optional
public String dataType; // optional
public String encoding; // optional
public Map<String,String> otherArgs; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
NAME((short)1, "name"),
DATA_TYPE((short)2, "dataType"),
ENCODING((short)3, "encoding"),
OTHER_ARGS((short)4, "otherArgs");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // NAME
return NAME;
case 2: // DATA_TYPE
return DATA_TYPE;
case 3: // ENCODING
return ENCODING;
case 4: // OTHER_ARGS
return OTHER_ARGS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.NAME,_Fields.DATA_TYPE,_Fields.ENCODING,_Fields.OTHER_ARGS};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.DATA_TYPE, new org.apache.thrift.meta_data.FieldMetaData("dataType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.ENCODING, new org.apache.thrift.meta_data.FieldMetaData("encoding", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.OTHER_ARGS, new org.apache.thrift.meta_data.FieldMetaData("otherArgs", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSColumnSchema.class, metaDataMap);
}
public TSColumnSchema() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSColumnSchema(TSColumnSchema other) {
if (other.isSetName()) {
this.name = other.name;
}
if (other.isSetDataType()) {
this.dataType = other.dataType;
}
if (other.isSetEncoding()) {
this.encoding = other.encoding;
}
if (other.isSetOtherArgs()) {
Map<String,String> __this__otherArgs = new HashMap<String,String>(other.otherArgs);
this.otherArgs = __this__otherArgs;
}
}
public TSColumnSchema deepCopy() {
return new TSColumnSchema(this);
}
@Override
public void clear() {
this.name = null;
this.dataType = null;
this.encoding = null;
this.otherArgs = null;
}
public String getName() {
return this.name;
}
public TSColumnSchema setName(String name) {
this.name = name;
return this;
}
public void unsetName() {
this.name = null;
}
/** Returns true if field name is set (has been assigned a value) and false otherwise */
public boolean isSetName() {
return this.name != null;
}
public void setNameIsSet(boolean value) {
if (!value) {
this.name = null;
}
}
public String getDataType() {
return this.dataType;
}
public TSColumnSchema setDataType(String dataType) {
this.dataType = dataType;
return this;
}
public void unsetDataType() {
this.dataType = null;
}
/** Returns true if field dataType is set (has been assigned a value) and false otherwise */
public boolean isSetDataType() {
return this.dataType != null;
}
public void setDataTypeIsSet(boolean value) {
if (!value) {
this.dataType = null;
}
}
public String getEncoding() {
return this.encoding;
}
public TSColumnSchema setEncoding(String encoding) {
this.encoding = encoding;
return this;
}
public void unsetEncoding() {
this.encoding = null;
}
/** Returns true if field encoding is set (has been assigned a value) and false otherwise */
public boolean isSetEncoding() {
return this.encoding != null;
}
public void setEncodingIsSet(boolean value) {
if (!value) {
this.encoding = null;
}
}
public int getOtherArgsSize() {
return (this.otherArgs == null) ? 0 : this.otherArgs.size();
}
public void putToOtherArgs(String key, String val) {
if (this.otherArgs == null) {
this.otherArgs = new HashMap<String,String>();
}
this.otherArgs.put(key, val);
}
public Map<String,String> getOtherArgs() {
return this.otherArgs;
}
public TSColumnSchema setOtherArgs(Map<String,String> otherArgs) {
this.otherArgs = otherArgs;
return this;
}
public void unsetOtherArgs() {
this.otherArgs = null;
}
/** Returns true if field otherArgs is set (has been assigned a value) and false otherwise */
public boolean isSetOtherArgs() {
return this.otherArgs != null;
}
public void setOtherArgsIsSet(boolean value) {
if (!value) {
this.otherArgs = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case NAME:
if (value == null) {
unsetName();
} else {
setName((String)value);
}
break;
case DATA_TYPE:
if (value == null) {
unsetDataType();
} else {
setDataType((String)value);
}
break;
case ENCODING:
if (value == null) {
unsetEncoding();
} else {
setEncoding((String)value);
}
break;
case OTHER_ARGS:
if (value == null) {
unsetOtherArgs();
} else {
setOtherArgs((Map<String,String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case NAME:
return getName();
case DATA_TYPE:
return getDataType();
case ENCODING:
return getEncoding();
case OTHER_ARGS:
return getOtherArgs();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case NAME:
return isSetName();
case DATA_TYPE:
return isSetDataType();
case ENCODING:
return isSetEncoding();
case OTHER_ARGS:
return isSetOtherArgs();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSColumnSchema)
return this.equals((TSColumnSchema)that);
return false;
}
public boolean equals(TSColumnSchema that) {
if (that == null)
return false;
boolean this_present_name = true && this.isSetName();
boolean that_present_name = true && that.isSetName();
if (this_present_name || that_present_name) {
if (!(this_present_name && that_present_name))
return false;
if (!this.name.equals(that.name))
return false;
}
boolean this_present_dataType = true && this.isSetDataType();
boolean that_present_dataType = true && that.isSetDataType();
if (this_present_dataType || that_present_dataType) {
if (!(this_present_dataType && that_present_dataType))
return false;
if (!this.dataType.equals(that.dataType))
return false;
}
boolean this_present_encoding = true && this.isSetEncoding();
boolean that_present_encoding = true && that.isSetEncoding();
if (this_present_encoding || that_present_encoding) {
if (!(this_present_encoding && that_present_encoding))
return false;
if (!this.encoding.equals(that.encoding))
return false;
}
boolean this_present_otherArgs = true && this.isSetOtherArgs();
boolean that_present_otherArgs = true && that.isSetOtherArgs();
if (this_present_otherArgs || that_present_otherArgs) {
if (!(this_present_otherArgs && that_present_otherArgs))
return false;
if (!this.otherArgs.equals(that.otherArgs))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_name = true && (isSetName());
list.add(present_name);
if (present_name)
list.add(name);
boolean present_dataType = true && (isSetDataType());
list.add(present_dataType);
if (present_dataType)
list.add(dataType);
boolean present_encoding = true && (isSetEncoding());
list.add(present_encoding);
if (present_encoding)
list.add(encoding);
boolean present_otherArgs = true && (isSetOtherArgs());
list.add(present_otherArgs);
if (present_otherArgs)
list.add(otherArgs);
return list.hashCode();
}
@Override
public int compareTo(TSColumnSchema other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetName()).compareTo(other.isSetName());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetName()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.name, other.name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDataType()).compareTo(other.isSetDataType());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDataType()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.dataType, other.dataType);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetEncoding()).compareTo(other.isSetEncoding());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetEncoding()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.encoding, other.encoding);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetOtherArgs()).compareTo(other.isSetOtherArgs());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOtherArgs()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.otherArgs, other.otherArgs);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSColumnSchema(");
boolean first = true;
if (isSetName()) {
sb.append("name:");
if (this.name == null) {
sb.append("null");
} else {
sb.append(this.name);
}
first = false;
}
if (isSetDataType()) {
if (!first) sb.append(", ");
sb.append("dataType:");
if (this.dataType == null) {
sb.append("null");
} else {
sb.append(this.dataType);
}
first = false;
}
if (isSetEncoding()) {
if (!first) sb.append(", ");
sb.append("encoding:");
if (this.encoding == null) {
sb.append("null");
} else {
sb.append(this.encoding);
}
first = false;
}
if (isSetOtherArgs()) {
if (!first) sb.append(", ");
sb.append("otherArgs:");
if (this.otherArgs == null) {
sb.append("null");
} else {
sb.append(this.otherArgs);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSColumnSchemaStandardSchemeFactory implements SchemeFactory {
public TSColumnSchemaStandardScheme getScheme() {
return new TSColumnSchemaStandardScheme();
}
}
private static class TSColumnSchemaStandardScheme extends StandardScheme<TSColumnSchema> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSColumnSchema struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // DATA_TYPE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.dataType = iprot.readString();
struct.setDataTypeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // ENCODING
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.encoding = iprot.readString();
struct.setEncodingIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // OTHER_ARGS
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map160 = iprot.readMapBegin();
struct.otherArgs = new HashMap<String,String>(2*_map160.size);
String _key161;
String _val162;
for (int _i163 = 0; _i163 < _map160.size; ++_i163)
{
_key161 = iprot.readString();
_val162 = iprot.readString();
struct.otherArgs.put(_key161, _val162);
}
iprot.readMapEnd();
}
struct.setOtherArgsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSColumnSchema struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.name != null) {
if (struct.isSetName()) {
oprot.writeFieldBegin(NAME_FIELD_DESC);
oprot.writeString(struct.name);
oprot.writeFieldEnd();
}
}
if (struct.dataType != null) {
if (struct.isSetDataType()) {
oprot.writeFieldBegin(DATA_TYPE_FIELD_DESC);
oprot.writeString(struct.dataType);
oprot.writeFieldEnd();
}
}
if (struct.encoding != null) {
if (struct.isSetEncoding()) {
oprot.writeFieldBegin(ENCODING_FIELD_DESC);
oprot.writeString(struct.encoding);
oprot.writeFieldEnd();
}
}
if (struct.otherArgs != null) {
if (struct.isSetOtherArgs()) {
oprot.writeFieldBegin(OTHER_ARGS_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.otherArgs.size()));
for (Map.Entry<String, String> _iter164 : struct.otherArgs.entrySet())
{
oprot.writeString(_iter164.getKey());
oprot.writeString(_iter164.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSColumnSchemaTupleSchemeFactory implements SchemeFactory {
public TSColumnSchemaTupleScheme getScheme() {
return new TSColumnSchemaTupleScheme();
}
}
private static class TSColumnSchemaTupleScheme extends TupleScheme<TSColumnSchema> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSColumnSchema struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetName()) {
optionals.set(0);
}
if (struct.isSetDataType()) {
optionals.set(1);
}
if (struct.isSetEncoding()) {
optionals.set(2);
}
if (struct.isSetOtherArgs()) {
optionals.set(3);
}
oprot.writeBitSet(optionals, 4);
if (struct.isSetName()) {
oprot.writeString(struct.name);
}
if (struct.isSetDataType()) {
oprot.writeString(struct.dataType);
}
if (struct.isSetEncoding()) {
oprot.writeString(struct.encoding);
}
if (struct.isSetOtherArgs()) {
{
oprot.writeI32(struct.otherArgs.size());
for (Map.Entry<String, String> _iter165 : struct.otherArgs.entrySet())
{
oprot.writeString(_iter165.getKey());
oprot.writeString(_iter165.getValue());
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSColumnSchema struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(4);
if (incoming.get(0)) {
struct.name = iprot.readString();
struct.setNameIsSet(true);
}
if (incoming.get(1)) {
struct.dataType = iprot.readString();
struct.setDataTypeIsSet(true);
}
if (incoming.get(2)) {
struct.encoding = iprot.readString();
struct.setEncodingIsSet(true);
}
if (incoming.get(3)) {
{
org.apache.thrift.protocol.TMap _map166 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.otherArgs = new HashMap<String,String>(2*_map166.size);
String _key167;
String _val168;
for (int _i169 = 0; _i169 < _map166.size; ++_i169)
{
_key167 = iprot.readString();
_val168 = iprot.readString();
struct.otherArgs.put(_key167, _val168);
}
}
struct.setOtherArgsIsSet(true);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,546 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSExecuteBatchStatementReq implements org.apache.thrift.TBase<TSExecuteBatchStatementReq, TSExecuteBatchStatementReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSExecuteBatchStatementReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteBatchStatementReq");
private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField STATEMENTS_FIELD_DESC = new org.apache.thrift.protocol.TField("statements", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSExecuteBatchStatementReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSExecuteBatchStatementReqTupleSchemeFactory());
}
public TS_SessionHandle sessionHandle; // required
public List<String> statements; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
SESSION_HANDLE((short)1, "sessionHandle"),
STATEMENTS((short)2, "statements");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // SESSION_HANDLE
return SESSION_HANDLE;
case 2: // STATEMENTS
return STATEMENTS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_SessionHandle.class)));
tmpMap.put(_Fields.STATEMENTS, new org.apache.thrift.meta_data.FieldMetaData("statements", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteBatchStatementReq.class, metaDataMap);
}
public TSExecuteBatchStatementReq() {
}
public TSExecuteBatchStatementReq(
TS_SessionHandle sessionHandle,
List<String> statements)
{
this();
this.sessionHandle = sessionHandle;
this.statements = statements;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSExecuteBatchStatementReq(TSExecuteBatchStatementReq other) {
if (other.isSetSessionHandle()) {
this.sessionHandle = new TS_SessionHandle(other.sessionHandle);
}
if (other.isSetStatements()) {
List<String> __this__statements = new ArrayList<String>(other.statements);
this.statements = __this__statements;
}
}
public TSExecuteBatchStatementReq deepCopy() {
return new TSExecuteBatchStatementReq(this);
}
@Override
public void clear() {
this.sessionHandle = null;
this.statements = null;
}
public TS_SessionHandle getSessionHandle() {
return this.sessionHandle;
}
public TSExecuteBatchStatementReq setSessionHandle(TS_SessionHandle sessionHandle) {
this.sessionHandle = sessionHandle;
return this;
}
public void unsetSessionHandle() {
this.sessionHandle = null;
}
/** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */
public boolean isSetSessionHandle() {
return this.sessionHandle != null;
}
public void setSessionHandleIsSet(boolean value) {
if (!value) {
this.sessionHandle = null;
}
}
public int getStatementsSize() {
return (this.statements == null) ? 0 : this.statements.size();
}
public java.util.Iterator<String> getStatementsIterator() {
return (this.statements == null) ? null : this.statements.iterator();
}
public void addToStatements(String elem) {
if (this.statements == null) {
this.statements = new ArrayList<String>();
}
this.statements.add(elem);
}
public List<String> getStatements() {
return this.statements;
}
public TSExecuteBatchStatementReq setStatements(List<String> statements) {
this.statements = statements;
return this;
}
public void unsetStatements() {
this.statements = null;
}
/** Returns true if field statements is set (has been assigned a value) and false otherwise */
public boolean isSetStatements() {
return this.statements != null;
}
public void setStatementsIsSet(boolean value) {
if (!value) {
this.statements = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SESSION_HANDLE:
if (value == null) {
unsetSessionHandle();
} else {
setSessionHandle((TS_SessionHandle)value);
}
break;
case STATEMENTS:
if (value == null) {
unsetStatements();
} else {
setStatements((List<String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SESSION_HANDLE:
return getSessionHandle();
case STATEMENTS:
return getStatements();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_HANDLE:
return isSetSessionHandle();
case STATEMENTS:
return isSetStatements();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSExecuteBatchStatementReq)
return this.equals((TSExecuteBatchStatementReq)that);
return false;
}
public boolean equals(TSExecuteBatchStatementReq that) {
if (that == null)
return false;
boolean this_present_sessionHandle = true && this.isSetSessionHandle();
boolean that_present_sessionHandle = true && that.isSetSessionHandle();
if (this_present_sessionHandle || that_present_sessionHandle) {
if (!(this_present_sessionHandle && that_present_sessionHandle))
return false;
if (!this.sessionHandle.equals(that.sessionHandle))
return false;
}
boolean this_present_statements = true && this.isSetStatements();
boolean that_present_statements = true && that.isSetStatements();
if (this_present_statements || that_present_statements) {
if (!(this_present_statements && that_present_statements))
return false;
if (!this.statements.equals(that.statements))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_sessionHandle = true && (isSetSessionHandle());
list.add(present_sessionHandle);
if (present_sessionHandle)
list.add(sessionHandle);
boolean present_statements = true && (isSetStatements());
list.add(present_statements);
if (present_statements)
list.add(statements);
return list.hashCode();
}
@Override
public int compareTo(TSExecuteBatchStatementReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSessionHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetStatements()).compareTo(other.isSetStatements());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatements()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statements, other.statements);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSExecuteBatchStatementReq(");
boolean first = true;
sb.append("sessionHandle:");
if (this.sessionHandle == null) {
sb.append("null");
} else {
sb.append(this.sessionHandle);
}
first = false;
if (!first) sb.append(", ");
sb.append("statements:");
if (this.statements == null) {
sb.append("null");
} else {
sb.append(this.statements);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (sessionHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString());
}
if (statements == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'statements' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (sessionHandle != null) {
sessionHandle.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSExecuteBatchStatementReqStandardSchemeFactory implements SchemeFactory {
public TSExecuteBatchStatementReqStandardScheme getScheme() {
return new TSExecuteBatchStatementReqStandardScheme();
}
}
private static class TSExecuteBatchStatementReqStandardScheme extends StandardScheme<TSExecuteBatchStatementReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // SESSION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // STATEMENTS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list44 = iprot.readListBegin();
struct.statements = new ArrayList<String>(_list44.size);
String _elem45;
for (int _i46 = 0; _i46 < _list44.size; ++_i46)
{
_elem45 = iprot.readString();
struct.statements.add(_elem45);
}
iprot.readListEnd();
}
struct.setStatementsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.sessionHandle != null) {
oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC);
struct.sessionHandle.write(oprot);
oprot.writeFieldEnd();
}
if (struct.statements != null) {
oprot.writeFieldBegin(STATEMENTS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.statements.size()));
for (String _iter47 : struct.statements)
{
oprot.writeString(_iter47);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSExecuteBatchStatementReqTupleSchemeFactory implements SchemeFactory {
public TSExecuteBatchStatementReqTupleScheme getScheme() {
return new TSExecuteBatchStatementReqTupleScheme();
}
}
private static class TSExecuteBatchStatementReqTupleScheme extends TupleScheme<TSExecuteBatchStatementReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.sessionHandle.write(oprot);
{
oprot.writeI32(struct.statements.size());
for (String _iter48 : struct.statements)
{
oprot.writeString(_iter48);
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
{
org.apache.thrift.protocol.TList _list49 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.statements = new ArrayList<String>(_list49.size);
String _elem50;
for (int _i51 = 0; _i51 < _list49.size; ++_i51)
{
_elem50 = iprot.readString();
struct.statements.add(_elem50);
}
}
struct.setStatementsIsSet(true);
}
}
}

View File

@ -0,0 +1,556 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSExecuteBatchStatementResp implements org.apache.thrift.TBase<TSExecuteBatchStatementResp, TSExecuteBatchStatementResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSExecuteBatchStatementResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteBatchStatementResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSExecuteBatchStatementRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSExecuteBatchStatementRespTupleSchemeFactory());
}
public TS_Status status; // required
public List<Integer> result; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status"),
RESULT((short)2, "result");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
case 2: // RESULT
return RESULT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.RESULT};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteBatchStatementResp.class, metaDataMap);
}
public TSExecuteBatchStatementResp() {
}
public TSExecuteBatchStatementResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSExecuteBatchStatementResp(TSExecuteBatchStatementResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
if (other.isSetResult()) {
List<Integer> __this__result = new ArrayList<Integer>(other.result);
this.result = __this__result;
}
}
public TSExecuteBatchStatementResp deepCopy() {
return new TSExecuteBatchStatementResp(this);
}
@Override
public void clear() {
this.status = null;
this.result = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSExecuteBatchStatementResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public int getResultSize() {
return (this.result == null) ? 0 : this.result.size();
}
public java.util.Iterator<Integer> getResultIterator() {
return (this.result == null) ? null : this.result.iterator();
}
public void addToResult(int elem) {
if (this.result == null) {
this.result = new ArrayList<Integer>();
}
this.result.add(elem);
}
public List<Integer> getResult() {
return this.result;
}
public TSExecuteBatchStatementResp setResult(List<Integer> result) {
this.result = result;
return this;
}
public void unsetResult() {
this.result = null;
}
/** Returns true if field result is set (has been assigned a value) and false otherwise */
public boolean isSetResult() {
return this.result != null;
}
public void setResultIsSet(boolean value) {
if (!value) {
this.result = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
case RESULT:
if (value == null) {
unsetResult();
} else {
setResult((List<Integer>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
case RESULT:
return getResult();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
case RESULT:
return isSetResult();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSExecuteBatchStatementResp)
return this.equals((TSExecuteBatchStatementResp)that);
return false;
}
public boolean equals(TSExecuteBatchStatementResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
boolean this_present_result = true && this.isSetResult();
boolean that_present_result = true && that.isSetResult();
if (this_present_result || that_present_result) {
if (!(this_present_result && that_present_result))
return false;
if (!this.result.equals(that.result))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
boolean present_result = true && (isSetResult());
list.add(present_result);
if (present_result)
list.add(result);
return list.hashCode();
}
@Override
public int compareTo(TSExecuteBatchStatementResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetResult()).compareTo(other.isSetResult());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetResult()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, other.result);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSExecuteBatchStatementResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (isSetResult()) {
if (!first) sb.append(", ");
sb.append("result:");
if (this.result == null) {
sb.append("null");
} else {
sb.append(this.result);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSExecuteBatchStatementRespStandardSchemeFactory implements SchemeFactory {
public TSExecuteBatchStatementRespStandardScheme getScheme() {
return new TSExecuteBatchStatementRespStandardScheme();
}
}
private static class TSExecuteBatchStatementRespStandardScheme extends StandardScheme<TSExecuteBatchStatementResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // RESULT
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list36 = iprot.readListBegin();
struct.result = new ArrayList<Integer>(_list36.size);
int _elem37;
for (int _i38 = 0; _i38 < _list36.size; ++_i38)
{
_elem37 = iprot.readI32();
struct.result.add(_elem37);
}
iprot.readListEnd();
}
struct.setResultIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
if (struct.result != null) {
if (struct.isSetResult()) {
oprot.writeFieldBegin(RESULT_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.result.size()));
for (int _iter39 : struct.result)
{
oprot.writeI32(_iter39);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSExecuteBatchStatementRespTupleSchemeFactory implements SchemeFactory {
public TSExecuteBatchStatementRespTupleScheme getScheme() {
return new TSExecuteBatchStatementRespTupleScheme();
}
}
private static class TSExecuteBatchStatementRespTupleScheme extends TupleScheme<TSExecuteBatchStatementResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
BitSet optionals = new BitSet();
if (struct.isSetResult()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetResult()) {
{
oprot.writeI32(struct.result.size());
for (int _iter40 : struct.result)
{
oprot.writeI32(_iter40);
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteBatchStatementResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list41 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32());
struct.result = new ArrayList<Integer>(_list41.size);
int _elem42;
for (int _i43 = 0; _i43 < _list41.size; ++_i43)
{
_elem42 = iprot.readI32();
struct.result.add(_elem42);
}
}
struct.setResultIsSet(true);
}
}
}
}

View File

@ -0,0 +1,497 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSExecuteStatementReq implements org.apache.thrift.TBase<TSExecuteStatementReq, TSExecuteStatementReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSExecuteStatementReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteStatementReq");
private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField STATEMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("statement", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSExecuteStatementReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSExecuteStatementReqTupleSchemeFactory());
}
public TS_SessionHandle sessionHandle; // required
public String statement; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
SESSION_HANDLE((short)1, "sessionHandle"),
STATEMENT((short)2, "statement");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // SESSION_HANDLE
return SESSION_HANDLE;
case 2: // STATEMENT
return STATEMENT;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_SessionHandle.class)));
tmpMap.put(_Fields.STATEMENT, new org.apache.thrift.meta_data.FieldMetaData("statement", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteStatementReq.class, metaDataMap);
}
public TSExecuteStatementReq() {
}
public TSExecuteStatementReq(
TS_SessionHandle sessionHandle,
String statement)
{
this();
this.sessionHandle = sessionHandle;
this.statement = statement;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSExecuteStatementReq(TSExecuteStatementReq other) {
if (other.isSetSessionHandle()) {
this.sessionHandle = new TS_SessionHandle(other.sessionHandle);
}
if (other.isSetStatement()) {
this.statement = other.statement;
}
}
public TSExecuteStatementReq deepCopy() {
return new TSExecuteStatementReq(this);
}
@Override
public void clear() {
this.sessionHandle = null;
this.statement = null;
}
public TS_SessionHandle getSessionHandle() {
return this.sessionHandle;
}
public TSExecuteStatementReq setSessionHandle(TS_SessionHandle sessionHandle) {
this.sessionHandle = sessionHandle;
return this;
}
public void unsetSessionHandle() {
this.sessionHandle = null;
}
/** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */
public boolean isSetSessionHandle() {
return this.sessionHandle != null;
}
public void setSessionHandleIsSet(boolean value) {
if (!value) {
this.sessionHandle = null;
}
}
public String getStatement() {
return this.statement;
}
public TSExecuteStatementReq setStatement(String statement) {
this.statement = statement;
return this;
}
public void unsetStatement() {
this.statement = null;
}
/** Returns true if field statement is set (has been assigned a value) and false otherwise */
public boolean isSetStatement() {
return this.statement != null;
}
public void setStatementIsSet(boolean value) {
if (!value) {
this.statement = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SESSION_HANDLE:
if (value == null) {
unsetSessionHandle();
} else {
setSessionHandle((TS_SessionHandle)value);
}
break;
case STATEMENT:
if (value == null) {
unsetStatement();
} else {
setStatement((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SESSION_HANDLE:
return getSessionHandle();
case STATEMENT:
return getStatement();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_HANDLE:
return isSetSessionHandle();
case STATEMENT:
return isSetStatement();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSExecuteStatementReq)
return this.equals((TSExecuteStatementReq)that);
return false;
}
public boolean equals(TSExecuteStatementReq that) {
if (that == null)
return false;
boolean this_present_sessionHandle = true && this.isSetSessionHandle();
boolean that_present_sessionHandle = true && that.isSetSessionHandle();
if (this_present_sessionHandle || that_present_sessionHandle) {
if (!(this_present_sessionHandle && that_present_sessionHandle))
return false;
if (!this.sessionHandle.equals(that.sessionHandle))
return false;
}
boolean this_present_statement = true && this.isSetStatement();
boolean that_present_statement = true && that.isSetStatement();
if (this_present_statement || that_present_statement) {
if (!(this_present_statement && that_present_statement))
return false;
if (!this.statement.equals(that.statement))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_sessionHandle = true && (isSetSessionHandle());
list.add(present_sessionHandle);
if (present_sessionHandle)
list.add(sessionHandle);
boolean present_statement = true && (isSetStatement());
list.add(present_statement);
if (present_statement)
list.add(statement);
return list.hashCode();
}
@Override
public int compareTo(TSExecuteStatementReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSessionHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetStatement()).compareTo(other.isSetStatement());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatement()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statement, other.statement);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSExecuteStatementReq(");
boolean first = true;
sb.append("sessionHandle:");
if (this.sessionHandle == null) {
sb.append("null");
} else {
sb.append(this.sessionHandle);
}
first = false;
if (!first) sb.append(", ");
sb.append("statement:");
if (this.statement == null) {
sb.append("null");
} else {
sb.append(this.statement);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (sessionHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' was not present! Struct: " + toString());
}
if (statement == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'statement' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (sessionHandle != null) {
sessionHandle.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSExecuteStatementReqStandardSchemeFactory implements SchemeFactory {
public TSExecuteStatementReqStandardScheme getScheme() {
return new TSExecuteStatementReqStandardScheme();
}
}
private static class TSExecuteStatementReqStandardScheme extends StandardScheme<TSExecuteStatementReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // SESSION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // STATEMENT
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.statement = iprot.readString();
struct.setStatementIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.sessionHandle != null) {
oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC);
struct.sessionHandle.write(oprot);
oprot.writeFieldEnd();
}
if (struct.statement != null) {
oprot.writeFieldBegin(STATEMENT_FIELD_DESC);
oprot.writeString(struct.statement);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSExecuteStatementReqTupleSchemeFactory implements SchemeFactory {
public TSExecuteStatementReqTupleScheme getScheme() {
return new TSExecuteStatementReqTupleScheme();
}
}
private static class TSExecuteStatementReqTupleScheme extends TupleScheme<TSExecuteStatementReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.sessionHandle.write(oprot);
oprot.writeString(struct.statement);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
struct.statement = iprot.readString();
struct.setStatementIsSet(true);
}
}
}

View File

@ -0,0 +1,668 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSExecuteStatementResp implements org.apache.thrift.TBase<TSExecuteStatementResp, TSExecuteStatementResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSExecuteStatementResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSExecuteStatementResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)2);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)3);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSExecuteStatementRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSExecuteStatementRespTupleSchemeFactory());
}
public TS_Status status; // required
public TSOperationHandle operationHandle; // optional
public List<String> columns; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status"),
OPERATION_HANDLE((short)2, "operationHandle"),
COLUMNS((short)3, "columns");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
case 2: // OPERATION_HANDLE
return OPERATION_HANDLE;
case 3: // COLUMNS
return COLUMNS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.OPERATION_HANDLE,_Fields.COLUMNS};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSOperationHandle.class)));
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSExecuteStatementResp.class, metaDataMap);
}
public TSExecuteStatementResp() {
}
public TSExecuteStatementResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSExecuteStatementResp(TSExecuteStatementResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
if (other.isSetOperationHandle()) {
this.operationHandle = new TSOperationHandle(other.operationHandle);
}
if (other.isSetColumns()) {
List<String> __this__columns = new ArrayList<String>(other.columns);
this.columns = __this__columns;
}
}
public TSExecuteStatementResp deepCopy() {
return new TSExecuteStatementResp(this);
}
@Override
public void clear() {
this.status = null;
this.operationHandle = null;
this.columns = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSExecuteStatementResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public TSOperationHandle getOperationHandle() {
return this.operationHandle;
}
public TSExecuteStatementResp setOperationHandle(TSOperationHandle operationHandle) {
this.operationHandle = operationHandle;
return this;
}
public void unsetOperationHandle() {
this.operationHandle = null;
}
/** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */
public boolean isSetOperationHandle() {
return this.operationHandle != null;
}
public void setOperationHandleIsSet(boolean value) {
if (!value) {
this.operationHandle = null;
}
}
public int getColumnsSize() {
return (this.columns == null) ? 0 : this.columns.size();
}
public java.util.Iterator<String> getColumnsIterator() {
return (this.columns == null) ? null : this.columns.iterator();
}
public void addToColumns(String elem) {
if (this.columns == null) {
this.columns = new ArrayList<String>();
}
this.columns.add(elem);
}
public List<String> getColumns() {
return this.columns;
}
public TSExecuteStatementResp setColumns(List<String> columns) {
this.columns = columns;
return this;
}
public void unsetColumns() {
this.columns = null;
}
/** Returns true if field columns is set (has been assigned a value) and false otherwise */
public boolean isSetColumns() {
return this.columns != null;
}
public void setColumnsIsSet(boolean value) {
if (!value) {
this.columns = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
case OPERATION_HANDLE:
if (value == null) {
unsetOperationHandle();
} else {
setOperationHandle((TSOperationHandle)value);
}
break;
case COLUMNS:
if (value == null) {
unsetColumns();
} else {
setColumns((List<String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
case OPERATION_HANDLE:
return getOperationHandle();
case COLUMNS:
return getColumns();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
case OPERATION_HANDLE:
return isSetOperationHandle();
case COLUMNS:
return isSetColumns();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSExecuteStatementResp)
return this.equals((TSExecuteStatementResp)that);
return false;
}
public boolean equals(TSExecuteStatementResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
boolean this_present_operationHandle = true && this.isSetOperationHandle();
boolean that_present_operationHandle = true && that.isSetOperationHandle();
if (this_present_operationHandle || that_present_operationHandle) {
if (!(this_present_operationHandle && that_present_operationHandle))
return false;
if (!this.operationHandle.equals(that.operationHandle))
return false;
}
boolean this_present_columns = true && this.isSetColumns();
boolean that_present_columns = true && that.isSetColumns();
if (this_present_columns || that_present_columns) {
if (!(this_present_columns && that_present_columns))
return false;
if (!this.columns.equals(that.columns))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
boolean present_operationHandle = true && (isSetOperationHandle());
list.add(present_operationHandle);
if (present_operationHandle)
list.add(operationHandle);
boolean present_columns = true && (isSetColumns());
list.add(present_columns);
if (present_columns)
list.add(columns);
return list.hashCode();
}
@Override
public int compareTo(TSExecuteStatementResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOperationHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetColumns()).compareTo(other.isSetColumns());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetColumns()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columns, other.columns);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSExecuteStatementResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (isSetOperationHandle()) {
if (!first) sb.append(", ");
sb.append("operationHandle:");
if (this.operationHandle == null) {
sb.append("null");
} else {
sb.append(this.operationHandle);
}
first = false;
}
if (isSetColumns()) {
if (!first) sb.append(", ");
sb.append("columns:");
if (this.columns == null) {
sb.append("null");
} else {
sb.append(this.columns);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
if (operationHandle != null) {
operationHandle.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSExecuteStatementRespStandardSchemeFactory implements SchemeFactory {
public TSExecuteStatementRespStandardScheme getScheme() {
return new TSExecuteStatementRespStandardScheme();
}
}
private static class TSExecuteStatementRespStandardScheme extends StandardScheme<TSExecuteStatementResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // OPERATION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // COLUMNS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list28 = iprot.readListBegin();
struct.columns = new ArrayList<String>(_list28.size);
String _elem29;
for (int _i30 = 0; _i30 < _list28.size; ++_i30)
{
_elem29 = iprot.readString();
struct.columns.add(_elem29);
}
iprot.readListEnd();
}
struct.setColumnsIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
if (struct.operationHandle != null) {
if (struct.isSetOperationHandle()) {
oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC);
struct.operationHandle.write(oprot);
oprot.writeFieldEnd();
}
}
if (struct.columns != null) {
if (struct.isSetColumns()) {
oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.columns.size()));
for (String _iter31 : struct.columns)
{
oprot.writeString(_iter31);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSExecuteStatementRespTupleSchemeFactory implements SchemeFactory {
public TSExecuteStatementRespTupleScheme getScheme() {
return new TSExecuteStatementRespTupleScheme();
}
}
private static class TSExecuteStatementRespTupleScheme extends TupleScheme<TSExecuteStatementResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
BitSet optionals = new BitSet();
if (struct.isSetOperationHandle()) {
optionals.set(0);
}
if (struct.isSetColumns()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetOperationHandle()) {
struct.operationHandle.write(oprot);
}
if (struct.isSetColumns()) {
{
oprot.writeI32(struct.columns.size());
for (String _iter32 : struct.columns)
{
oprot.writeString(_iter32);
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSExecuteStatementResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TList _list33 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.columns = new ArrayList<String>(_list33.size);
String _elem34;
for (int _i35 = 0; _i35 < _list33.size; ++_i35)
{
_elem34 = iprot.readString();
struct.columns.add(_elem34);
}
}
struct.setColumnsIsSet(true);
}
}
}
}

View File

@ -0,0 +1,285 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSFetchMetadataReq implements org.apache.thrift.TBase<TSFetchMetadataReq, TSFetchMetadataReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSFetchMetadataReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchMetadataReq");
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSFetchMetadataReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSFetchMetadataReqTupleSchemeFactory());
}
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
;
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchMetadataReq.class, metaDataMap);
}
public TSFetchMetadataReq() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSFetchMetadataReq(TSFetchMetadataReq other) {
}
public TSFetchMetadataReq deepCopy() {
return new TSFetchMetadataReq(this);
}
@Override
public void clear() {
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSFetchMetadataReq)
return this.equals((TSFetchMetadataReq)that);
return false;
}
public boolean equals(TSFetchMetadataReq that) {
if (that == null)
return false;
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
return list.hashCode();
}
@Override
public int compareTo(TSFetchMetadataReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSFetchMetadataReq(");
boolean first = true;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSFetchMetadataReqStandardSchemeFactory implements SchemeFactory {
public TSFetchMetadataReqStandardScheme getScheme() {
return new TSFetchMetadataReqStandardScheme();
}
}
private static class TSFetchMetadataReqStandardScheme extends StandardScheme<TSFetchMetadataReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchMetadataReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchMetadataReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSFetchMetadataReqTupleSchemeFactory implements SchemeFactory {
public TSFetchMetadataReqTupleScheme getScheme() {
return new TSFetchMetadataReqTupleScheme();
}
}
private static class TSFetchMetadataReqTupleScheme extends TupleScheme<TSFetchMetadataReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
}
}
}

View File

@ -0,0 +1,918 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSFetchMetadataResp implements org.apache.thrift.TBase<TSFetchMetadataResp, TSFetchMetadataResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSFetchMetadataResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchMetadataResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField SERIES_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("seriesMap", org.apache.thrift.protocol.TType.MAP, (short)2);
private static final org.apache.thrift.protocol.TField DELTA_OBJECT_MAP_FIELD_DESC = new org.apache.thrift.protocol.TField("deltaObjectMap", org.apache.thrift.protocol.TType.MAP, (short)3);
private static final org.apache.thrift.protocol.TField METADATA_IN_JSON_FIELD_DESC = new org.apache.thrift.protocol.TField("metadataInJson", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSFetchMetadataRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSFetchMetadataRespTupleSchemeFactory());
}
public TS_Status status; // required
public Map<String,List<TSColumnSchema>> seriesMap; // optional
public Map<String,List<String>> deltaObjectMap; // optional
public String metadataInJson; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status"),
SERIES_MAP((short)2, "seriesMap"),
DELTA_OBJECT_MAP((short)3, "deltaObjectMap"),
METADATA_IN_JSON((short)4, "metadataInJson");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
case 2: // SERIES_MAP
return SERIES_MAP;
case 3: // DELTA_OBJECT_MAP
return DELTA_OBJECT_MAP;
case 4: // METADATA_IN_JSON
return METADATA_IN_JSON;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.SERIES_MAP,_Fields.DELTA_OBJECT_MAP,_Fields.METADATA_IN_JSON};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
tmpMap.put(_Fields.SERIES_MAP, new org.apache.thrift.meta_data.FieldMetaData("seriesMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSColumnSchema")))));
tmpMap.put(_Fields.DELTA_OBJECT_MAP, new org.apache.thrift.meta_data.FieldMetaData("deltaObjectMap", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))));
tmpMap.put(_Fields.METADATA_IN_JSON, new org.apache.thrift.meta_data.FieldMetaData("metadataInJson", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchMetadataResp.class, metaDataMap);
}
public TSFetchMetadataResp() {
}
public TSFetchMetadataResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSFetchMetadataResp(TSFetchMetadataResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
if (other.isSetSeriesMap()) {
Map<String,List<TSColumnSchema>> __this__seriesMap = new HashMap<String,List<TSColumnSchema>>(other.seriesMap.size());
for (Map.Entry<String, List<TSColumnSchema>> other_element : other.seriesMap.entrySet()) {
String other_element_key = other_element.getKey();
List<TSColumnSchema> other_element_value = other_element.getValue();
String __this__seriesMap_copy_key = other_element_key;
List<TSColumnSchema> __this__seriesMap_copy_value = new ArrayList<TSColumnSchema>(other_element_value.size());
for (TSColumnSchema other_element_value_element : other_element_value) {
__this__seriesMap_copy_value.add(other_element_value_element);
}
__this__seriesMap.put(__this__seriesMap_copy_key, __this__seriesMap_copy_value);
}
this.seriesMap = __this__seriesMap;
}
if (other.isSetDeltaObjectMap()) {
Map<String,List<String>> __this__deltaObjectMap = new HashMap<String,List<String>>(other.deltaObjectMap.size());
for (Map.Entry<String, List<String>> other_element : other.deltaObjectMap.entrySet()) {
String other_element_key = other_element.getKey();
List<String> other_element_value = other_element.getValue();
String __this__deltaObjectMap_copy_key = other_element_key;
List<String> __this__deltaObjectMap_copy_value = new ArrayList<String>(other_element_value);
__this__deltaObjectMap.put(__this__deltaObjectMap_copy_key, __this__deltaObjectMap_copy_value);
}
this.deltaObjectMap = __this__deltaObjectMap;
}
if (other.isSetMetadataInJson()) {
this.metadataInJson = other.metadataInJson;
}
}
public TSFetchMetadataResp deepCopy() {
return new TSFetchMetadataResp(this);
}
@Override
public void clear() {
this.status = null;
this.seriesMap = null;
this.deltaObjectMap = null;
this.metadataInJson = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSFetchMetadataResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public int getSeriesMapSize() {
return (this.seriesMap == null) ? 0 : this.seriesMap.size();
}
public void putToSeriesMap(String key, List<TSColumnSchema> val) {
if (this.seriesMap == null) {
this.seriesMap = new HashMap<String,List<TSColumnSchema>>();
}
this.seriesMap.put(key, val);
}
public Map<String,List<TSColumnSchema>> getSeriesMap() {
return this.seriesMap;
}
public TSFetchMetadataResp setSeriesMap(Map<String,List<TSColumnSchema>> seriesMap) {
this.seriesMap = seriesMap;
return this;
}
public void unsetSeriesMap() {
this.seriesMap = null;
}
/** Returns true if field seriesMap is set (has been assigned a value) and false otherwise */
public boolean isSetSeriesMap() {
return this.seriesMap != null;
}
public void setSeriesMapIsSet(boolean value) {
if (!value) {
this.seriesMap = null;
}
}
public int getDeltaObjectMapSize() {
return (this.deltaObjectMap == null) ? 0 : this.deltaObjectMap.size();
}
public void putToDeltaObjectMap(String key, List<String> val) {
if (this.deltaObjectMap == null) {
this.deltaObjectMap = new HashMap<String,List<String>>();
}
this.deltaObjectMap.put(key, val);
}
public Map<String,List<String>> getDeltaObjectMap() {
return this.deltaObjectMap;
}
public TSFetchMetadataResp setDeltaObjectMap(Map<String,List<String>> deltaObjectMap) {
this.deltaObjectMap = deltaObjectMap;
return this;
}
public void unsetDeltaObjectMap() {
this.deltaObjectMap = null;
}
/** Returns true if field deltaObjectMap is set (has been assigned a value) and false otherwise */
public boolean isSetDeltaObjectMap() {
return this.deltaObjectMap != null;
}
public void setDeltaObjectMapIsSet(boolean value) {
if (!value) {
this.deltaObjectMap = null;
}
}
public String getMetadataInJson() {
return this.metadataInJson;
}
public TSFetchMetadataResp setMetadataInJson(String metadataInJson) {
this.metadataInJson = metadataInJson;
return this;
}
public void unsetMetadataInJson() {
this.metadataInJson = null;
}
/** Returns true if field metadataInJson is set (has been assigned a value) and false otherwise */
public boolean isSetMetadataInJson() {
return this.metadataInJson != null;
}
public void setMetadataInJsonIsSet(boolean value) {
if (!value) {
this.metadataInJson = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
case SERIES_MAP:
if (value == null) {
unsetSeriesMap();
} else {
setSeriesMap((Map<String,List<TSColumnSchema>>)value);
}
break;
case DELTA_OBJECT_MAP:
if (value == null) {
unsetDeltaObjectMap();
} else {
setDeltaObjectMap((Map<String,List<String>>)value);
}
break;
case METADATA_IN_JSON:
if (value == null) {
unsetMetadataInJson();
} else {
setMetadataInJson((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
case SERIES_MAP:
return getSeriesMap();
case DELTA_OBJECT_MAP:
return getDeltaObjectMap();
case METADATA_IN_JSON:
return getMetadataInJson();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
case SERIES_MAP:
return isSetSeriesMap();
case DELTA_OBJECT_MAP:
return isSetDeltaObjectMap();
case METADATA_IN_JSON:
return isSetMetadataInJson();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSFetchMetadataResp)
return this.equals((TSFetchMetadataResp)that);
return false;
}
public boolean equals(TSFetchMetadataResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
boolean this_present_seriesMap = true && this.isSetSeriesMap();
boolean that_present_seriesMap = true && that.isSetSeriesMap();
if (this_present_seriesMap || that_present_seriesMap) {
if (!(this_present_seriesMap && that_present_seriesMap))
return false;
if (!this.seriesMap.equals(that.seriesMap))
return false;
}
boolean this_present_deltaObjectMap = true && this.isSetDeltaObjectMap();
boolean that_present_deltaObjectMap = true && that.isSetDeltaObjectMap();
if (this_present_deltaObjectMap || that_present_deltaObjectMap) {
if (!(this_present_deltaObjectMap && that_present_deltaObjectMap))
return false;
if (!this.deltaObjectMap.equals(that.deltaObjectMap))
return false;
}
boolean this_present_metadataInJson = true && this.isSetMetadataInJson();
boolean that_present_metadataInJson = true && that.isSetMetadataInJson();
if (this_present_metadataInJson || that_present_metadataInJson) {
if (!(this_present_metadataInJson && that_present_metadataInJson))
return false;
if (!this.metadataInJson.equals(that.metadataInJson))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
boolean present_seriesMap = true && (isSetSeriesMap());
list.add(present_seriesMap);
if (present_seriesMap)
list.add(seriesMap);
boolean present_deltaObjectMap = true && (isSetDeltaObjectMap());
list.add(present_deltaObjectMap);
if (present_deltaObjectMap)
list.add(deltaObjectMap);
boolean present_metadataInJson = true && (isSetMetadataInJson());
list.add(present_metadataInJson);
if (present_metadataInJson)
list.add(metadataInJson);
return list.hashCode();
}
@Override
public int compareTo(TSFetchMetadataResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetSeriesMap()).compareTo(other.isSetSeriesMap());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSeriesMap()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.seriesMap, other.seriesMap);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDeltaObjectMap()).compareTo(other.isSetDeltaObjectMap());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDeltaObjectMap()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.deltaObjectMap, other.deltaObjectMap);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMetadataInJson()).compareTo(other.isSetMetadataInJson());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMetadataInJson()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.metadataInJson, other.metadataInJson);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSFetchMetadataResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (isSetSeriesMap()) {
if (!first) sb.append(", ");
sb.append("seriesMap:");
if (this.seriesMap == null) {
sb.append("null");
} else {
sb.append(this.seriesMap);
}
first = false;
}
if (isSetDeltaObjectMap()) {
if (!first) sb.append(", ");
sb.append("deltaObjectMap:");
if (this.deltaObjectMap == null) {
sb.append("null");
} else {
sb.append(this.deltaObjectMap);
}
first = false;
}
if (isSetMetadataInJson()) {
if (!first) sb.append(", ");
sb.append("metadataInJson:");
if (this.metadataInJson == null) {
sb.append("null");
} else {
sb.append(this.metadataInJson);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSFetchMetadataRespStandardSchemeFactory implements SchemeFactory {
public TSFetchMetadataRespStandardScheme getScheme() {
return new TSFetchMetadataRespStandardScheme();
}
}
private static class TSFetchMetadataRespStandardScheme extends StandardScheme<TSFetchMetadataResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchMetadataResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // SERIES_MAP
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map124 = iprot.readMapBegin();
struct.seriesMap = new HashMap<String,List<TSColumnSchema>>(2*_map124.size);
String _key125;
List<TSColumnSchema> _val126;
for (int _i127 = 0; _i127 < _map124.size; ++_i127)
{
_key125 = iprot.readString();
{
org.apache.thrift.protocol.TList _list128 = iprot.readListBegin();
_val126 = new ArrayList<TSColumnSchema>(_list128.size);
TSColumnSchema _elem129;
for (int _i130 = 0; _i130 < _list128.size; ++_i130)
{
_elem129 = new TSColumnSchema();
_elem129.read(iprot);
_val126.add(_elem129);
}
iprot.readListEnd();
}
struct.seriesMap.put(_key125, _val126);
}
iprot.readMapEnd();
}
struct.setSeriesMapIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // DELTA_OBJECT_MAP
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map131 = iprot.readMapBegin();
struct.deltaObjectMap = new HashMap<String,List<String>>(2*_map131.size);
String _key132;
List<String> _val133;
for (int _i134 = 0; _i134 < _map131.size; ++_i134)
{
_key132 = iprot.readString();
{
org.apache.thrift.protocol.TList _list135 = iprot.readListBegin();
_val133 = new ArrayList<String>(_list135.size);
String _elem136;
for (int _i137 = 0; _i137 < _list135.size; ++_i137)
{
_elem136 = iprot.readString();
_val133.add(_elem136);
}
iprot.readListEnd();
}
struct.deltaObjectMap.put(_key132, _val133);
}
iprot.readMapEnd();
}
struct.setDeltaObjectMapIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // METADATA_IN_JSON
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.metadataInJson = iprot.readString();
struct.setMetadataInJsonIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchMetadataResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
if (struct.seriesMap != null) {
if (struct.isSetSeriesMap()) {
oprot.writeFieldBegin(SERIES_MAP_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, struct.seriesMap.size()));
for (Map.Entry<String, List<TSColumnSchema>> _iter138 : struct.seriesMap.entrySet())
{
oprot.writeString(_iter138.getKey());
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter138.getValue().size()));
for (TSColumnSchema _iter139 : _iter138.getValue())
{
_iter139.write(oprot);
}
oprot.writeListEnd();
}
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
if (struct.deltaObjectMap != null) {
if (struct.isSetDeltaObjectMap()) {
oprot.writeFieldBegin(DELTA_OBJECT_MAP_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, struct.deltaObjectMap.size()));
for (Map.Entry<String, List<String>> _iter140 : struct.deltaObjectMap.entrySet())
{
oprot.writeString(_iter140.getKey());
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, _iter140.getValue().size()));
for (String _iter141 : _iter140.getValue())
{
oprot.writeString(_iter141);
}
oprot.writeListEnd();
}
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
if (struct.metadataInJson != null) {
if (struct.isSetMetadataInJson()) {
oprot.writeFieldBegin(METADATA_IN_JSON_FIELD_DESC);
oprot.writeString(struct.metadataInJson);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSFetchMetadataRespTupleSchemeFactory implements SchemeFactory {
public TSFetchMetadataRespTupleScheme getScheme() {
return new TSFetchMetadataRespTupleScheme();
}
}
private static class TSFetchMetadataRespTupleScheme extends TupleScheme<TSFetchMetadataResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
BitSet optionals = new BitSet();
if (struct.isSetSeriesMap()) {
optionals.set(0);
}
if (struct.isSetDeltaObjectMap()) {
optionals.set(1);
}
if (struct.isSetMetadataInJson()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetSeriesMap()) {
{
oprot.writeI32(struct.seriesMap.size());
for (Map.Entry<String, List<TSColumnSchema>> _iter142 : struct.seriesMap.entrySet())
{
oprot.writeString(_iter142.getKey());
{
oprot.writeI32(_iter142.getValue().size());
for (TSColumnSchema _iter143 : _iter142.getValue())
{
_iter143.write(oprot);
}
}
}
}
}
if (struct.isSetDeltaObjectMap()) {
{
oprot.writeI32(struct.deltaObjectMap.size());
for (Map.Entry<String, List<String>> _iter144 : struct.deltaObjectMap.entrySet())
{
oprot.writeString(_iter144.getKey());
{
oprot.writeI32(_iter144.getValue().size());
for (String _iter145 : _iter144.getValue())
{
oprot.writeString(_iter145);
}
}
}
}
}
if (struct.isSetMetadataInJson()) {
oprot.writeString(struct.metadataInJson);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchMetadataResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TMap _map146 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, iprot.readI32());
struct.seriesMap = new HashMap<String,List<TSColumnSchema>>(2*_map146.size);
String _key147;
List<TSColumnSchema> _val148;
for (int _i149 = 0; _i149 < _map146.size; ++_i149)
{
_key147 = iprot.readString();
{
org.apache.thrift.protocol.TList _list150 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
_val148 = new ArrayList<TSColumnSchema>(_list150.size);
TSColumnSchema _elem151;
for (int _i152 = 0; _i152 < _list150.size; ++_i152)
{
_elem151 = new TSColumnSchema();
_elem151.read(iprot);
_val148.add(_elem151);
}
}
struct.seriesMap.put(_key147, _val148);
}
}
struct.setSeriesMapIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TMap _map153 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, iprot.readI32());
struct.deltaObjectMap = new HashMap<String,List<String>>(2*_map153.size);
String _key154;
List<String> _val155;
for (int _i156 = 0; _i156 < _map153.size; ++_i156)
{
_key154 = iprot.readString();
{
org.apache.thrift.protocol.TList _list157 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
_val155 = new ArrayList<String>(_list157.size);
String _elem158;
for (int _i159 = 0; _i159 < _list157.size; ++_i159)
{
_elem158 = iprot.readString();
_val155.add(_elem158);
}
}
struct.deltaObjectMap.put(_key154, _val155);
}
}
struct.setDeltaObjectMapIsSet(true);
}
if (incoming.get(2)) {
struct.metadataInJson = iprot.readString();
struct.setMetadataInJsonIsSet(true);
}
}
}
}

View File

@ -0,0 +1,491 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSFetchResultsReq implements org.apache.thrift.TBase<TSFetchResultsReq, TSFetchResultsReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSFetchResultsReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchResultsReq");
private static final org.apache.thrift.protocol.TField STATEMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("statement", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField FETCH_SIZE_FIELD_DESC = new org.apache.thrift.protocol.TField("fetch_size", org.apache.thrift.protocol.TType.I32, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSFetchResultsReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSFetchResultsReqTupleSchemeFactory());
}
public String statement; // required
public int fetch_size; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATEMENT((short)1, "statement"),
FETCH_SIZE((short)2, "fetch_size");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATEMENT
return STATEMENT;
case 2: // FETCH_SIZE
return FETCH_SIZE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __FETCH_SIZE_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATEMENT, new org.apache.thrift.meta_data.FieldMetaData("statement", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.FETCH_SIZE, new org.apache.thrift.meta_data.FieldMetaData("fetch_size", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchResultsReq.class, metaDataMap);
}
public TSFetchResultsReq() {
}
public TSFetchResultsReq(
String statement,
int fetch_size)
{
this();
this.statement = statement;
this.fetch_size = fetch_size;
setFetch_sizeIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSFetchResultsReq(TSFetchResultsReq other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetStatement()) {
this.statement = other.statement;
}
this.fetch_size = other.fetch_size;
}
public TSFetchResultsReq deepCopy() {
return new TSFetchResultsReq(this);
}
@Override
public void clear() {
this.statement = null;
setFetch_sizeIsSet(false);
this.fetch_size = 0;
}
public String getStatement() {
return this.statement;
}
public TSFetchResultsReq setStatement(String statement) {
this.statement = statement;
return this;
}
public void unsetStatement() {
this.statement = null;
}
/** Returns true if field statement is set (has been assigned a value) and false otherwise */
public boolean isSetStatement() {
return this.statement != null;
}
public void setStatementIsSet(boolean value) {
if (!value) {
this.statement = null;
}
}
public int getFetch_size() {
return this.fetch_size;
}
public TSFetchResultsReq setFetch_size(int fetch_size) {
this.fetch_size = fetch_size;
setFetch_sizeIsSet(true);
return this;
}
public void unsetFetch_size() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID);
}
/** Returns true if field fetch_size is set (has been assigned a value) and false otherwise */
public boolean isSetFetch_size() {
return EncodingUtils.testBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID);
}
public void setFetch_sizeIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __FETCH_SIZE_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATEMENT:
if (value == null) {
unsetStatement();
} else {
setStatement((String)value);
}
break;
case FETCH_SIZE:
if (value == null) {
unsetFetch_size();
} else {
setFetch_size((Integer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATEMENT:
return getStatement();
case FETCH_SIZE:
return Integer.valueOf(getFetch_size());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATEMENT:
return isSetStatement();
case FETCH_SIZE:
return isSetFetch_size();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSFetchResultsReq)
return this.equals((TSFetchResultsReq)that);
return false;
}
public boolean equals(TSFetchResultsReq that) {
if (that == null)
return false;
boolean this_present_statement = true && this.isSetStatement();
boolean that_present_statement = true && that.isSetStatement();
if (this_present_statement || that_present_statement) {
if (!(this_present_statement && that_present_statement))
return false;
if (!this.statement.equals(that.statement))
return false;
}
boolean this_present_fetch_size = true;
boolean that_present_fetch_size = true;
if (this_present_fetch_size || that_present_fetch_size) {
if (!(this_present_fetch_size && that_present_fetch_size))
return false;
if (this.fetch_size != that.fetch_size)
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_statement = true && (isSetStatement());
list.add(present_statement);
if (present_statement)
list.add(statement);
boolean present_fetch_size = true;
list.add(present_fetch_size);
if (present_fetch_size)
list.add(fetch_size);
return list.hashCode();
}
@Override
public int compareTo(TSFetchResultsReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatement()).compareTo(other.isSetStatement());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatement()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statement, other.statement);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetFetch_size()).compareTo(other.isSetFetch_size());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFetch_size()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fetch_size, other.fetch_size);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSFetchResultsReq(");
boolean first = true;
sb.append("statement:");
if (this.statement == null) {
sb.append("null");
} else {
sb.append(this.statement);
}
first = false;
if (!first) sb.append(", ");
sb.append("fetch_size:");
sb.append(this.fetch_size);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (statement == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'statement' was not present! Struct: " + toString());
}
// alas, we cannot check 'fetch_size' because it's a primitive and you chose the non-beans generator.
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSFetchResultsReqStandardSchemeFactory implements SchemeFactory {
public TSFetchResultsReqStandardScheme getScheme() {
return new TSFetchResultsReqStandardScheme();
}
}
private static class TSFetchResultsReqStandardScheme extends StandardScheme<TSFetchResultsReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchResultsReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATEMENT
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.statement = iprot.readString();
struct.setStatementIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // FETCH_SIZE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.fetch_size = iprot.readI32();
struct.setFetch_sizeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
if (!struct.isSetFetch_size()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'fetch_size' was not found in serialized data! Struct: " + toString());
}
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchResultsReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.statement != null) {
oprot.writeFieldBegin(STATEMENT_FIELD_DESC);
oprot.writeString(struct.statement);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(FETCH_SIZE_FIELD_DESC);
oprot.writeI32(struct.fetch_size);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSFetchResultsReqTupleSchemeFactory implements SchemeFactory {
public TSFetchResultsReqTupleScheme getScheme() {
return new TSFetchResultsReqTupleScheme();
}
}
private static class TSFetchResultsReqTupleScheme extends TupleScheme<TSFetchResultsReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeString(struct.statement);
oprot.writeI32(struct.fetch_size);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.statement = iprot.readString();
struct.setStatementIsSet(true);
struct.fetch_size = iprot.readI32();
struct.setFetch_sizeIsSet(true);
}
}
}

View File

@ -0,0 +1,612 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSFetchResultsResp implements org.apache.thrift.TBase<TSFetchResultsResp, TSFetchResultsResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSFetchResultsResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSFetchResultsResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField HAS_RESULT_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("hasResultSet", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final org.apache.thrift.protocol.TField QUERY_DATA_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("queryDataSet", org.apache.thrift.protocol.TType.STRUCT, (short)3);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSFetchResultsRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSFetchResultsRespTupleSchemeFactory());
}
public TS_Status status; // required
public boolean hasResultSet; // required
public TSQueryDataSet queryDataSet; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status"),
HAS_RESULT_SET((short)2, "hasResultSet"),
QUERY_DATA_SET((short)3, "queryDataSet");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
case 2: // HAS_RESULT_SET
return HAS_RESULT_SET;
case 3: // QUERY_DATA_SET
return QUERY_DATA_SET;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __HASRESULTSET_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.QUERY_DATA_SET};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
tmpMap.put(_Fields.HAS_RESULT_SET, new org.apache.thrift.meta_data.FieldMetaData("hasResultSet", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.QUERY_DATA_SET, new org.apache.thrift.meta_data.FieldMetaData("queryDataSet", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSQueryDataSet.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSFetchResultsResp.class, metaDataMap);
}
public TSFetchResultsResp() {
}
public TSFetchResultsResp(
TS_Status status,
boolean hasResultSet)
{
this();
this.status = status;
this.hasResultSet = hasResultSet;
setHasResultSetIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSFetchResultsResp(TSFetchResultsResp other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
this.hasResultSet = other.hasResultSet;
if (other.isSetQueryDataSet()) {
this.queryDataSet = new TSQueryDataSet(other.queryDataSet);
}
}
public TSFetchResultsResp deepCopy() {
return new TSFetchResultsResp(this);
}
@Override
public void clear() {
this.status = null;
setHasResultSetIsSet(false);
this.hasResultSet = false;
this.queryDataSet = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSFetchResultsResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public boolean isHasResultSet() {
return this.hasResultSet;
}
public TSFetchResultsResp setHasResultSet(boolean hasResultSet) {
this.hasResultSet = hasResultSet;
setHasResultSetIsSet(true);
return this;
}
public void unsetHasResultSet() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HASRESULTSET_ISSET_ID);
}
/** Returns true if field hasResultSet is set (has been assigned a value) and false otherwise */
public boolean isSetHasResultSet() {
return EncodingUtils.testBit(__isset_bitfield, __HASRESULTSET_ISSET_ID);
}
public void setHasResultSetIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HASRESULTSET_ISSET_ID, value);
}
public TSQueryDataSet getQueryDataSet() {
return this.queryDataSet;
}
public TSFetchResultsResp setQueryDataSet(TSQueryDataSet queryDataSet) {
this.queryDataSet = queryDataSet;
return this;
}
public void unsetQueryDataSet() {
this.queryDataSet = null;
}
/** Returns true if field queryDataSet is set (has been assigned a value) and false otherwise */
public boolean isSetQueryDataSet() {
return this.queryDataSet != null;
}
public void setQueryDataSetIsSet(boolean value) {
if (!value) {
this.queryDataSet = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
case HAS_RESULT_SET:
if (value == null) {
unsetHasResultSet();
} else {
setHasResultSet((Boolean)value);
}
break;
case QUERY_DATA_SET:
if (value == null) {
unsetQueryDataSet();
} else {
setQueryDataSet((TSQueryDataSet)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
case HAS_RESULT_SET:
return Boolean.valueOf(isHasResultSet());
case QUERY_DATA_SET:
return getQueryDataSet();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
case HAS_RESULT_SET:
return isSetHasResultSet();
case QUERY_DATA_SET:
return isSetQueryDataSet();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSFetchResultsResp)
return this.equals((TSFetchResultsResp)that);
return false;
}
public boolean equals(TSFetchResultsResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
boolean this_present_hasResultSet = true;
boolean that_present_hasResultSet = true;
if (this_present_hasResultSet || that_present_hasResultSet) {
if (!(this_present_hasResultSet && that_present_hasResultSet))
return false;
if (this.hasResultSet != that.hasResultSet)
return false;
}
boolean this_present_queryDataSet = true && this.isSetQueryDataSet();
boolean that_present_queryDataSet = true && that.isSetQueryDataSet();
if (this_present_queryDataSet || that_present_queryDataSet) {
if (!(this_present_queryDataSet && that_present_queryDataSet))
return false;
if (!this.queryDataSet.equals(that.queryDataSet))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
boolean present_hasResultSet = true;
list.add(present_hasResultSet);
if (present_hasResultSet)
list.add(hasResultSet);
boolean present_queryDataSet = true && (isSetQueryDataSet());
list.add(present_queryDataSet);
if (present_queryDataSet)
list.add(queryDataSet);
return list.hashCode();
}
@Override
public int compareTo(TSFetchResultsResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetHasResultSet()).compareTo(other.isSetHasResultSet());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetHasResultSet()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasResultSet, other.hasResultSet);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetQueryDataSet()).compareTo(other.isSetQueryDataSet());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetQueryDataSet()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.queryDataSet, other.queryDataSet);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSFetchResultsResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (!first) sb.append(", ");
sb.append("hasResultSet:");
sb.append(this.hasResultSet);
first = false;
if (isSetQueryDataSet()) {
if (!first) sb.append(", ");
sb.append("queryDataSet:");
if (this.queryDataSet == null) {
sb.append("null");
} else {
sb.append(this.queryDataSet);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// alas, we cannot check 'hasResultSet' because it's a primitive and you chose the non-beans generator.
// check for sub-struct validity
if (status != null) {
status.validate();
}
if (queryDataSet != null) {
queryDataSet.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSFetchResultsRespStandardSchemeFactory implements SchemeFactory {
public TSFetchResultsRespStandardScheme getScheme() {
return new TSFetchResultsRespStandardScheme();
}
}
private static class TSFetchResultsRespStandardScheme extends StandardScheme<TSFetchResultsResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSFetchResultsResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // HAS_RESULT_SET
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.hasResultSet = iprot.readBool();
struct.setHasResultSetIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // QUERY_DATA_SET
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.queryDataSet = new TSQueryDataSet();
struct.queryDataSet.read(iprot);
struct.setQueryDataSetIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
if (!struct.isSetHasResultSet()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'hasResultSet' was not found in serialized data! Struct: " + toString());
}
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSFetchResultsResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(HAS_RESULT_SET_FIELD_DESC);
oprot.writeBool(struct.hasResultSet);
oprot.writeFieldEnd();
if (struct.queryDataSet != null) {
if (struct.isSetQueryDataSet()) {
oprot.writeFieldBegin(QUERY_DATA_SET_FIELD_DESC);
struct.queryDataSet.write(oprot);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSFetchResultsRespTupleSchemeFactory implements SchemeFactory {
public TSFetchResultsRespTupleScheme getScheme() {
return new TSFetchResultsRespTupleScheme();
}
}
private static class TSFetchResultsRespTupleScheme extends TupleScheme<TSFetchResultsResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
oprot.writeBool(struct.hasResultSet);
BitSet optionals = new BitSet();
if (struct.isSetQueryDataSet()) {
optionals.set(0);
}
oprot.writeBitSet(optionals, 1);
if (struct.isSetQueryDataSet()) {
struct.queryDataSet.write(oprot);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSFetchResultsResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
struct.hasResultSet = iprot.readBool();
struct.setHasResultSetIsSet(true);
BitSet incoming = iprot.readBitSet(1);
if (incoming.get(0)) {
struct.queryDataSet = new TSQueryDataSet();
struct.queryDataSet.read(iprot);
struct.setQueryDataSetIsSet(true);
}
}
}
}

View File

@ -0,0 +1,393 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSGetOperationStatusReq implements org.apache.thrift.TBase<TSGetOperationStatusReq, TSGetOperationStatusReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSGetOperationStatusReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSGetOperationStatusReq");
private static final org.apache.thrift.protocol.TField OPERATION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("operationHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSGetOperationStatusReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSGetOperationStatusReqTupleSchemeFactory());
}
public TSOperationHandle operationHandle; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
OPERATION_HANDLE((short)1, "operationHandle");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // OPERATION_HANDLE
return OPERATION_HANDLE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.OPERATION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("operationHandle", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSOperationHandle")));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSGetOperationStatusReq.class, metaDataMap);
}
public TSGetOperationStatusReq() {
}
public TSGetOperationStatusReq(
TSOperationHandle operationHandle)
{
this();
this.operationHandle = operationHandle;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSGetOperationStatusReq(TSGetOperationStatusReq other) {
if (other.isSetOperationHandle()) {
this.operationHandle = other.operationHandle;
}
}
public TSGetOperationStatusReq deepCopy() {
return new TSGetOperationStatusReq(this);
}
@Override
public void clear() {
this.operationHandle = null;
}
public TSOperationHandle getOperationHandle() {
return this.operationHandle;
}
public TSGetOperationStatusReq setOperationHandle(TSOperationHandle operationHandle) {
this.operationHandle = operationHandle;
return this;
}
public void unsetOperationHandle() {
this.operationHandle = null;
}
/** Returns true if field operationHandle is set (has been assigned a value) and false otherwise */
public boolean isSetOperationHandle() {
return this.operationHandle != null;
}
public void setOperationHandleIsSet(boolean value) {
if (!value) {
this.operationHandle = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case OPERATION_HANDLE:
if (value == null) {
unsetOperationHandle();
} else {
setOperationHandle((TSOperationHandle)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case OPERATION_HANDLE:
return getOperationHandle();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OPERATION_HANDLE:
return isSetOperationHandle();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSGetOperationStatusReq)
return this.equals((TSGetOperationStatusReq)that);
return false;
}
public boolean equals(TSGetOperationStatusReq that) {
if (that == null)
return false;
boolean this_present_operationHandle = true && this.isSetOperationHandle();
boolean that_present_operationHandle = true && that.isSetOperationHandle();
if (this_present_operationHandle || that_present_operationHandle) {
if (!(this_present_operationHandle && that_present_operationHandle))
return false;
if (!this.operationHandle.equals(that.operationHandle))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_operationHandle = true && (isSetOperationHandle());
list.add(present_operationHandle);
if (present_operationHandle)
list.add(operationHandle);
return list.hashCode();
}
@Override
public int compareTo(TSGetOperationStatusReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetOperationHandle()).compareTo(other.isSetOperationHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOperationHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationHandle, other.operationHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSGetOperationStatusReq(");
boolean first = true;
sb.append("operationHandle:");
if (this.operationHandle == null) {
sb.append("null");
} else {
sb.append(this.operationHandle);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (operationHandle == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationHandle' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSGetOperationStatusReqStandardSchemeFactory implements SchemeFactory {
public TSGetOperationStatusReqStandardScheme getScheme() {
return new TSGetOperationStatusReqStandardScheme();
}
}
private static class TSGetOperationStatusReqStandardScheme extends StandardScheme<TSGetOperationStatusReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // OPERATION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.operationHandle != null) {
oprot.writeFieldBegin(OPERATION_HANDLE_FIELD_DESC);
struct.operationHandle.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSGetOperationStatusReqTupleSchemeFactory implements SchemeFactory {
public TSGetOperationStatusReqTupleScheme getScheme() {
return new TSGetOperationStatusReqTupleScheme();
}
}
private static class TSGetOperationStatusReqTupleScheme extends TupleScheme<TSGetOperationStatusReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.operationHandle.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.operationHandle = new TSOperationHandle();
struct.operationHandle.read(iprot);
struct.setOperationHandleIsSet(true);
}
}
}

View File

@ -0,0 +1,396 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSGetOperationStatusResp implements org.apache.thrift.TBase<TSGetOperationStatusResp, TSGetOperationStatusResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSGetOperationStatusResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSGetOperationStatusResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSGetOperationStatusRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSGetOperationStatusRespTupleSchemeFactory());
}
public TS_Status status; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TS_Status.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSGetOperationStatusResp.class, metaDataMap);
}
public TSGetOperationStatusResp() {
}
public TSGetOperationStatusResp(
TS_Status status)
{
this();
this.status = status;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSGetOperationStatusResp(TSGetOperationStatusResp other) {
if (other.isSetStatus()) {
this.status = new TS_Status(other.status);
}
}
public TSGetOperationStatusResp deepCopy() {
return new TSGetOperationStatusResp(this);
}
@Override
public void clear() {
this.status = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSGetOperationStatusResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSGetOperationStatusResp)
return this.equals((TSGetOperationStatusResp)that);
return false;
}
public boolean equals(TSGetOperationStatusResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
return list.hashCode();
}
@Override
public int compareTo(TSGetOperationStatusResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSGetOperationStatusResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (status != null) {
status.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSGetOperationStatusRespStandardSchemeFactory implements SchemeFactory {
public TSGetOperationStatusRespStandardScheme getScheme() {
return new TSGetOperationStatusRespStandardScheme();
}
}
private static class TSGetOperationStatusRespStandardScheme extends StandardScheme<TSGetOperationStatusResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSGetOperationStatusRespTupleSchemeFactory implements SchemeFactory {
public TSGetOperationStatusRespTupleScheme getScheme() {
return new TSGetOperationStatusRespTupleScheme();
}
}
private static class TSGetOperationStatusRespTupleScheme extends TupleScheme<TSGetOperationStatusResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSGetOperationStatusResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
}
}
}

View File

@ -0,0 +1,512 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSHandleIdentifier implements org.apache.thrift.TBase<TSHandleIdentifier, TSHandleIdentifier._Fields>, java.io.Serializable, Cloneable, Comparable<TSHandleIdentifier> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSHandleIdentifier");
private static final org.apache.thrift.protocol.TField GUID_FIELD_DESC = new org.apache.thrift.protocol.TField("guid", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField SECRET_FIELD_DESC = new org.apache.thrift.protocol.TField("secret", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSHandleIdentifierStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSHandleIdentifierTupleSchemeFactory());
}
public ByteBuffer guid; // required
public ByteBuffer secret; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
GUID((short)1, "guid"),
SECRET((short)2, "secret");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // GUID
return GUID;
case 2: // SECRET
return SECRET;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.GUID, new org.apache.thrift.meta_data.FieldMetaData("guid", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.SECRET, new org.apache.thrift.meta_data.FieldMetaData("secret", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSHandleIdentifier.class, metaDataMap);
}
public TSHandleIdentifier() {
}
public TSHandleIdentifier(
ByteBuffer guid,
ByteBuffer secret)
{
this();
this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid);
this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSHandleIdentifier(TSHandleIdentifier other) {
if (other.isSetGuid()) {
this.guid = org.apache.thrift.TBaseHelper.copyBinary(other.guid);
}
if (other.isSetSecret()) {
this.secret = org.apache.thrift.TBaseHelper.copyBinary(other.secret);
}
}
public TSHandleIdentifier deepCopy() {
return new TSHandleIdentifier(this);
}
@Override
public void clear() {
this.guid = null;
this.secret = null;
}
public byte[] getGuid() {
setGuid(org.apache.thrift.TBaseHelper.rightSize(guid));
return guid == null ? null : guid.array();
}
public ByteBuffer bufferForGuid() {
return org.apache.thrift.TBaseHelper.copyBinary(guid);
}
public TSHandleIdentifier setGuid(byte[] guid) {
this.guid = guid == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(guid, guid.length));
return this;
}
public TSHandleIdentifier setGuid(ByteBuffer guid) {
this.guid = org.apache.thrift.TBaseHelper.copyBinary(guid);
return this;
}
public void unsetGuid() {
this.guid = null;
}
/** Returns true if field guid is set (has been assigned a value) and false otherwise */
public boolean isSetGuid() {
return this.guid != null;
}
public void setGuidIsSet(boolean value) {
if (!value) {
this.guid = null;
}
}
public byte[] getSecret() {
setSecret(org.apache.thrift.TBaseHelper.rightSize(secret));
return secret == null ? null : secret.array();
}
public ByteBuffer bufferForSecret() {
return org.apache.thrift.TBaseHelper.copyBinary(secret);
}
public TSHandleIdentifier setSecret(byte[] secret) {
this.secret = secret == null ? (ByteBuffer)null : ByteBuffer.wrap(Arrays.copyOf(secret, secret.length));
return this;
}
public TSHandleIdentifier setSecret(ByteBuffer secret) {
this.secret = org.apache.thrift.TBaseHelper.copyBinary(secret);
return this;
}
public void unsetSecret() {
this.secret = null;
}
/** Returns true if field secret is set (has been assigned a value) and false otherwise */
public boolean isSetSecret() {
return this.secret != null;
}
public void setSecretIsSet(boolean value) {
if (!value) {
this.secret = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case GUID:
if (value == null) {
unsetGuid();
} else {
setGuid((ByteBuffer)value);
}
break;
case SECRET:
if (value == null) {
unsetSecret();
} else {
setSecret((ByteBuffer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case GUID:
return getGuid();
case SECRET:
return getSecret();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case GUID:
return isSetGuid();
case SECRET:
return isSetSecret();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSHandleIdentifier)
return this.equals((TSHandleIdentifier)that);
return false;
}
public boolean equals(TSHandleIdentifier that) {
if (that == null)
return false;
boolean this_present_guid = true && this.isSetGuid();
boolean that_present_guid = true && that.isSetGuid();
if (this_present_guid || that_present_guid) {
if (!(this_present_guid && that_present_guid))
return false;
if (!this.guid.equals(that.guid))
return false;
}
boolean this_present_secret = true && this.isSetSecret();
boolean that_present_secret = true && that.isSetSecret();
if (this_present_secret || that_present_secret) {
if (!(this_present_secret && that_present_secret))
return false;
if (!this.secret.equals(that.secret))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_guid = true && (isSetGuid());
list.add(present_guid);
if (present_guid)
list.add(guid);
boolean present_secret = true && (isSetSecret());
list.add(present_secret);
if (present_secret)
list.add(secret);
return list.hashCode();
}
@Override
public int compareTo(TSHandleIdentifier other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetGuid()).compareTo(other.isSetGuid());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetGuid()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.guid, other.guid);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetSecret()).compareTo(other.isSetSecret());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSecret()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.secret, other.secret);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSHandleIdentifier(");
boolean first = true;
sb.append("guid:");
if (this.guid == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.guid, sb);
}
first = false;
if (!first) sb.append(", ");
sb.append("secret:");
if (this.secret == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.secret, sb);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (guid == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'guid' was not present! Struct: " + toString());
}
if (secret == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'secret' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSHandleIdentifierStandardSchemeFactory implements SchemeFactory {
public TSHandleIdentifierStandardScheme getScheme() {
return new TSHandleIdentifierStandardScheme();
}
}
private static class TSHandleIdentifierStandardScheme extends StandardScheme<TSHandleIdentifier> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSHandleIdentifier struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // GUID
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.guid = iprot.readBinary();
struct.setGuidIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // SECRET
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.secret = iprot.readBinary();
struct.setSecretIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSHandleIdentifier struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.guid != null) {
oprot.writeFieldBegin(GUID_FIELD_DESC);
oprot.writeBinary(struct.guid);
oprot.writeFieldEnd();
}
if (struct.secret != null) {
oprot.writeFieldBegin(SECRET_FIELD_DESC);
oprot.writeBinary(struct.secret);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSHandleIdentifierTupleSchemeFactory implements SchemeFactory {
public TSHandleIdentifierTupleScheme getScheme() {
return new TSHandleIdentifierTupleScheme();
}
}
private static class TSHandleIdentifierTupleScheme extends TupleScheme<TSHandleIdentifier> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSHandleIdentifier struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeBinary(struct.guid);
oprot.writeBinary(struct.secret);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSHandleIdentifier struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.guid = iprot.readBinary();
struct.setGuidIsSet(true);
struct.secret = iprot.readBinary();
struct.setSecretIsSet(true);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,787 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSOpenSessionReq implements org.apache.thrift.TBase<TSOpenSessionReq, TSOpenSessionReq._Fields>, java.io.Serializable, Cloneable, Comparable<TSOpenSessionReq> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOpenSessionReq");
private static final org.apache.thrift.protocol.TField CLIENT_PROTOCOL_FIELD_DESC = new org.apache.thrift.protocol.TField("client_protocol", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField USERNAME_FIELD_DESC = new org.apache.thrift.protocol.TField("username", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField PASSWORD_FIELD_DESC = new org.apache.thrift.protocol.TField("password", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField CONFIGURATION_FIELD_DESC = new org.apache.thrift.protocol.TField("configuration", org.apache.thrift.protocol.TType.MAP, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSOpenSessionReqStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSOpenSessionReqTupleSchemeFactory());
}
/**
*
* @see TSProtocolVersion
*/
public TSProtocolVersion client_protocol; // required
public String username; // optional
public String password; // optional
public Map<String,String> configuration; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
*
* @see TSProtocolVersion
*/
CLIENT_PROTOCOL((short)1, "client_protocol"),
USERNAME((short)2, "username"),
PASSWORD((short)3, "password"),
CONFIGURATION((short)4, "configuration");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // CLIENT_PROTOCOL
return CLIENT_PROTOCOL;
case 2: // USERNAME
return USERNAME;
case 3: // PASSWORD
return PASSWORD;
case 4: // CONFIGURATION
return CONFIGURATION;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.USERNAME,_Fields.PASSWORD,_Fields.CONFIGURATION};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.CLIENT_PROTOCOL, new org.apache.thrift.meta_data.FieldMetaData("client_protocol", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TSProtocolVersion.class)));
tmpMap.put(_Fields.USERNAME, new org.apache.thrift.meta_data.FieldMetaData("username", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.PASSWORD, new org.apache.thrift.meta_data.FieldMetaData("password", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.CONFIGURATION, new org.apache.thrift.meta_data.FieldMetaData("configuration", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOpenSessionReq.class, metaDataMap);
}
public TSOpenSessionReq() {
this.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1;
}
public TSOpenSessionReq(
TSProtocolVersion client_protocol)
{
this();
this.client_protocol = client_protocol;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSOpenSessionReq(TSOpenSessionReq other) {
if (other.isSetClient_protocol()) {
this.client_protocol = other.client_protocol;
}
if (other.isSetUsername()) {
this.username = other.username;
}
if (other.isSetPassword()) {
this.password = other.password;
}
if (other.isSetConfiguration()) {
Map<String,String> __this__configuration = new HashMap<String,String>(other.configuration);
this.configuration = __this__configuration;
}
}
public TSOpenSessionReq deepCopy() {
return new TSOpenSessionReq(this);
}
@Override
public void clear() {
this.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1;
this.username = null;
this.password = null;
this.configuration = null;
}
/**
*
* @see TSProtocolVersion
*/
public TSProtocolVersion getClient_protocol() {
return this.client_protocol;
}
/**
*
* @see TSProtocolVersion
*/
public TSOpenSessionReq setClient_protocol(TSProtocolVersion client_protocol) {
this.client_protocol = client_protocol;
return this;
}
public void unsetClient_protocol() {
this.client_protocol = null;
}
/** Returns true if field client_protocol is set (has been assigned a value) and false otherwise */
public boolean isSetClient_protocol() {
return this.client_protocol != null;
}
public void setClient_protocolIsSet(boolean value) {
if (!value) {
this.client_protocol = null;
}
}
public String getUsername() {
return this.username;
}
public TSOpenSessionReq setUsername(String username) {
this.username = username;
return this;
}
public void unsetUsername() {
this.username = null;
}
/** Returns true if field username is set (has been assigned a value) and false otherwise */
public boolean isSetUsername() {
return this.username != null;
}
public void setUsernameIsSet(boolean value) {
if (!value) {
this.username = null;
}
}
public String getPassword() {
return this.password;
}
public TSOpenSessionReq setPassword(String password) {
this.password = password;
return this;
}
public void unsetPassword() {
this.password = null;
}
/** Returns true if field password is set (has been assigned a value) and false otherwise */
public boolean isSetPassword() {
return this.password != null;
}
public void setPasswordIsSet(boolean value) {
if (!value) {
this.password = null;
}
}
public int getConfigurationSize() {
return (this.configuration == null) ? 0 : this.configuration.size();
}
public void putToConfiguration(String key, String val) {
if (this.configuration == null) {
this.configuration = new HashMap<String,String>();
}
this.configuration.put(key, val);
}
public Map<String,String> getConfiguration() {
return this.configuration;
}
public TSOpenSessionReq setConfiguration(Map<String,String> configuration) {
this.configuration = configuration;
return this;
}
public void unsetConfiguration() {
this.configuration = null;
}
/** Returns true if field configuration is set (has been assigned a value) and false otherwise */
public boolean isSetConfiguration() {
return this.configuration != null;
}
public void setConfigurationIsSet(boolean value) {
if (!value) {
this.configuration = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case CLIENT_PROTOCOL:
if (value == null) {
unsetClient_protocol();
} else {
setClient_protocol((TSProtocolVersion)value);
}
break;
case USERNAME:
if (value == null) {
unsetUsername();
} else {
setUsername((String)value);
}
break;
case PASSWORD:
if (value == null) {
unsetPassword();
} else {
setPassword((String)value);
}
break;
case CONFIGURATION:
if (value == null) {
unsetConfiguration();
} else {
setConfiguration((Map<String,String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case CLIENT_PROTOCOL:
return getClient_protocol();
case USERNAME:
return getUsername();
case PASSWORD:
return getPassword();
case CONFIGURATION:
return getConfiguration();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case CLIENT_PROTOCOL:
return isSetClient_protocol();
case USERNAME:
return isSetUsername();
case PASSWORD:
return isSetPassword();
case CONFIGURATION:
return isSetConfiguration();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSOpenSessionReq)
return this.equals((TSOpenSessionReq)that);
return false;
}
public boolean equals(TSOpenSessionReq that) {
if (that == null)
return false;
boolean this_present_client_protocol = true && this.isSetClient_protocol();
boolean that_present_client_protocol = true && that.isSetClient_protocol();
if (this_present_client_protocol || that_present_client_protocol) {
if (!(this_present_client_protocol && that_present_client_protocol))
return false;
if (!this.client_protocol.equals(that.client_protocol))
return false;
}
boolean this_present_username = true && this.isSetUsername();
boolean that_present_username = true && that.isSetUsername();
if (this_present_username || that_present_username) {
if (!(this_present_username && that_present_username))
return false;
if (!this.username.equals(that.username))
return false;
}
boolean this_present_password = true && this.isSetPassword();
boolean that_present_password = true && that.isSetPassword();
if (this_present_password || that_present_password) {
if (!(this_present_password && that_present_password))
return false;
if (!this.password.equals(that.password))
return false;
}
boolean this_present_configuration = true && this.isSetConfiguration();
boolean that_present_configuration = true && that.isSetConfiguration();
if (this_present_configuration || that_present_configuration) {
if (!(this_present_configuration && that_present_configuration))
return false;
if (!this.configuration.equals(that.configuration))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_client_protocol = true && (isSetClient_protocol());
list.add(present_client_protocol);
if (present_client_protocol)
list.add(client_protocol.getValue());
boolean present_username = true && (isSetUsername());
list.add(present_username);
if (present_username)
list.add(username);
boolean present_password = true && (isSetPassword());
list.add(present_password);
if (present_password)
list.add(password);
boolean present_configuration = true && (isSetConfiguration());
list.add(present_configuration);
if (present_configuration)
list.add(configuration);
return list.hashCode();
}
@Override
public int compareTo(TSOpenSessionReq other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetClient_protocol()).compareTo(other.isSetClient_protocol());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetClient_protocol()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.client_protocol, other.client_protocol);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetUsername()).compareTo(other.isSetUsername());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUsername()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.username, other.username);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetPassword()).compareTo(other.isSetPassword());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPassword()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.password, other.password);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetConfiguration()).compareTo(other.isSetConfiguration());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetConfiguration()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.configuration, other.configuration);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSOpenSessionReq(");
boolean first = true;
sb.append("client_protocol:");
if (this.client_protocol == null) {
sb.append("null");
} else {
sb.append(this.client_protocol);
}
first = false;
if (isSetUsername()) {
if (!first) sb.append(", ");
sb.append("username:");
if (this.username == null) {
sb.append("null");
} else {
sb.append(this.username);
}
first = false;
}
if (isSetPassword()) {
if (!first) sb.append(", ");
sb.append("password:");
if (this.password == null) {
sb.append("null");
} else {
sb.append(this.password);
}
first = false;
}
if (isSetConfiguration()) {
if (!first) sb.append(", ");
sb.append("configuration:");
if (this.configuration == null) {
sb.append("null");
} else {
sb.append(this.configuration);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (client_protocol == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'client_protocol' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSOpenSessionReqStandardSchemeFactory implements SchemeFactory {
public TSOpenSessionReqStandardScheme getScheme() {
return new TSOpenSessionReqStandardScheme();
}
}
private static class TSOpenSessionReqStandardScheme extends StandardScheme<TSOpenSessionReq> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSOpenSessionReq struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // CLIENT_PROTOCOL
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32());
struct.setClient_protocolIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // USERNAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // PASSWORD
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.password = iprot.readString();
struct.setPasswordIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // CONFIGURATION
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
struct.configuration = new HashMap<String,String>(2*_map0.size);
String _key1;
String _val2;
for (int _i3 = 0; _i3 < _map0.size; ++_i3)
{
_key1 = iprot.readString();
_val2 = iprot.readString();
struct.configuration.put(_key1, _val2);
}
iprot.readMapEnd();
}
struct.setConfigurationIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSOpenSessionReq struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.client_protocol != null) {
oprot.writeFieldBegin(CLIENT_PROTOCOL_FIELD_DESC);
oprot.writeI32(struct.client_protocol.getValue());
oprot.writeFieldEnd();
}
if (struct.username != null) {
if (struct.isSetUsername()) {
oprot.writeFieldBegin(USERNAME_FIELD_DESC);
oprot.writeString(struct.username);
oprot.writeFieldEnd();
}
}
if (struct.password != null) {
if (struct.isSetPassword()) {
oprot.writeFieldBegin(PASSWORD_FIELD_DESC);
oprot.writeString(struct.password);
oprot.writeFieldEnd();
}
}
if (struct.configuration != null) {
if (struct.isSetConfiguration()) {
oprot.writeFieldBegin(CONFIGURATION_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.configuration.size()));
for (Map.Entry<String, String> _iter4 : struct.configuration.entrySet())
{
oprot.writeString(_iter4.getKey());
oprot.writeString(_iter4.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSOpenSessionReqTupleSchemeFactory implements SchemeFactory {
public TSOpenSessionReqTupleScheme getScheme() {
return new TSOpenSessionReqTupleScheme();
}
}
private static class TSOpenSessionReqTupleScheme extends TupleScheme<TSOpenSessionReq> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionReq struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeI32(struct.client_protocol.getValue());
BitSet optionals = new BitSet();
if (struct.isSetUsername()) {
optionals.set(0);
}
if (struct.isSetPassword()) {
optionals.set(1);
}
if (struct.isSetConfiguration()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetUsername()) {
oprot.writeString(struct.username);
}
if (struct.isSetPassword()) {
oprot.writeString(struct.password);
}
if (struct.isSetConfiguration()) {
{
oprot.writeI32(struct.configuration.size());
for (Map.Entry<String, String> _iter5 : struct.configuration.entrySet())
{
oprot.writeString(_iter5.getKey());
oprot.writeString(_iter5.getValue());
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionReq struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.client_protocol = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32());
struct.setClient_protocolIsSet(true);
BitSet incoming = iprot.readBitSet(3);
if (incoming.get(0)) {
struct.username = iprot.readString();
struct.setUsernameIsSet(true);
}
if (incoming.get(1)) {
struct.password = iprot.readString();
struct.setPasswordIsSet(true);
}
if (incoming.get(2)) {
{
org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.configuration = new HashMap<String,String>(2*_map6.size);
String _key7;
String _val8;
for (int _i9 = 0; _i9 < _map6.size; ++_i9)
{
_key7 = iprot.readString();
_val8 = iprot.readString();
struct.configuration.put(_key7, _val8);
}
}
struct.setConfigurationIsSet(true);
}
}
}
}

View File

@ -0,0 +1,785 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSOpenSessionResp implements org.apache.thrift.TBase<TSOpenSessionResp, TSOpenSessionResp._Fields>, java.io.Serializable, Cloneable, Comparable<TSOpenSessionResp> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOpenSessionResp");
private static final org.apache.thrift.protocol.TField STATUS_FIELD_DESC = new org.apache.thrift.protocol.TField("status", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField SERVER_PROTOCOL_VERSION_FIELD_DESC = new org.apache.thrift.protocol.TField("serverProtocolVersion", org.apache.thrift.protocol.TType.I32, (short)2);
private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)3);
private static final org.apache.thrift.protocol.TField CONFIGURATION_FIELD_DESC = new org.apache.thrift.protocol.TField("configuration", org.apache.thrift.protocol.TType.MAP, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSOpenSessionRespStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSOpenSessionRespTupleSchemeFactory());
}
public TS_Status status; // required
/**
*
* @see TSProtocolVersion
*/
public TSProtocolVersion serverProtocolVersion; // required
public TS_SessionHandle sessionHandle; // optional
public Map<String,String> configuration; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
STATUS((short)1, "status"),
/**
*
* @see TSProtocolVersion
*/
SERVER_PROTOCOL_VERSION((short)2, "serverProtocolVersion"),
SESSION_HANDLE((short)3, "sessionHandle"),
CONFIGURATION((short)4, "configuration");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS
return STATUS;
case 2: // SERVER_PROTOCOL_VERSION
return SERVER_PROTOCOL_VERSION;
case 3: // SESSION_HANDLE
return SESSION_HANDLE;
case 4: // CONFIGURATION
return CONFIGURATION;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final _Fields optionals[] = {_Fields.SESSION_HANDLE,_Fields.CONFIGURATION};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS, new org.apache.thrift.meta_data.FieldMetaData("status", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_Status")));
tmpMap.put(_Fields.SERVER_PROTOCOL_VERSION, new org.apache.thrift.meta_data.FieldMetaData("serverProtocolVersion", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TSProtocolVersion.class)));
tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TS_SessionHandle")));
tmpMap.put(_Fields.CONFIGURATION, new org.apache.thrift.meta_data.FieldMetaData("configuration", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOpenSessionResp.class, metaDataMap);
}
public TSOpenSessionResp() {
this.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1;
}
public TSOpenSessionResp(
TS_Status status,
TSProtocolVersion serverProtocolVersion)
{
this();
this.status = status;
this.serverProtocolVersion = serverProtocolVersion;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSOpenSessionResp(TSOpenSessionResp other) {
if (other.isSetStatus()) {
this.status = other.status;
}
if (other.isSetServerProtocolVersion()) {
this.serverProtocolVersion = other.serverProtocolVersion;
}
if (other.isSetSessionHandle()) {
this.sessionHandle = other.sessionHandle;
}
if (other.isSetConfiguration()) {
Map<String,String> __this__configuration = new HashMap<String,String>(other.configuration);
this.configuration = __this__configuration;
}
}
public TSOpenSessionResp deepCopy() {
return new TSOpenSessionResp(this);
}
@Override
public void clear() {
this.status = null;
this.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1;
this.sessionHandle = null;
this.configuration = null;
}
public TS_Status getStatus() {
return this.status;
}
public TSOpenSessionResp setStatus(TS_Status status) {
this.status = status;
return this;
}
public void unsetStatus() {
this.status = null;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return this.status != null;
}
public void setStatusIsSet(boolean value) {
if (!value) {
this.status = null;
}
}
/**
*
* @see TSProtocolVersion
*/
public TSProtocolVersion getServerProtocolVersion() {
return this.serverProtocolVersion;
}
/**
*
* @see TSProtocolVersion
*/
public TSOpenSessionResp setServerProtocolVersion(TSProtocolVersion serverProtocolVersion) {
this.serverProtocolVersion = serverProtocolVersion;
return this;
}
public void unsetServerProtocolVersion() {
this.serverProtocolVersion = null;
}
/** Returns true if field serverProtocolVersion is set (has been assigned a value) and false otherwise */
public boolean isSetServerProtocolVersion() {
return this.serverProtocolVersion != null;
}
public void setServerProtocolVersionIsSet(boolean value) {
if (!value) {
this.serverProtocolVersion = null;
}
}
public TS_SessionHandle getSessionHandle() {
return this.sessionHandle;
}
public TSOpenSessionResp setSessionHandle(TS_SessionHandle sessionHandle) {
this.sessionHandle = sessionHandle;
return this;
}
public void unsetSessionHandle() {
this.sessionHandle = null;
}
/** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */
public boolean isSetSessionHandle() {
return this.sessionHandle != null;
}
public void setSessionHandleIsSet(boolean value) {
if (!value) {
this.sessionHandle = null;
}
}
public int getConfigurationSize() {
return (this.configuration == null) ? 0 : this.configuration.size();
}
public void putToConfiguration(String key, String val) {
if (this.configuration == null) {
this.configuration = new HashMap<String,String>();
}
this.configuration.put(key, val);
}
public Map<String,String> getConfiguration() {
return this.configuration;
}
public TSOpenSessionResp setConfiguration(Map<String,String> configuration) {
this.configuration = configuration;
return this;
}
public void unsetConfiguration() {
this.configuration = null;
}
/** Returns true if field configuration is set (has been assigned a value) and false otherwise */
public boolean isSetConfiguration() {
return this.configuration != null;
}
public void setConfigurationIsSet(boolean value) {
if (!value) {
this.configuration = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS:
if (value == null) {
unsetStatus();
} else {
setStatus((TS_Status)value);
}
break;
case SERVER_PROTOCOL_VERSION:
if (value == null) {
unsetServerProtocolVersion();
} else {
setServerProtocolVersion((TSProtocolVersion)value);
}
break;
case SESSION_HANDLE:
if (value == null) {
unsetSessionHandle();
} else {
setSessionHandle((TS_SessionHandle)value);
}
break;
case CONFIGURATION:
if (value == null) {
unsetConfiguration();
} else {
setConfiguration((Map<String,String>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS:
return getStatus();
case SERVER_PROTOCOL_VERSION:
return getServerProtocolVersion();
case SESSION_HANDLE:
return getSessionHandle();
case CONFIGURATION:
return getConfiguration();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS:
return isSetStatus();
case SERVER_PROTOCOL_VERSION:
return isSetServerProtocolVersion();
case SESSION_HANDLE:
return isSetSessionHandle();
case CONFIGURATION:
return isSetConfiguration();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSOpenSessionResp)
return this.equals((TSOpenSessionResp)that);
return false;
}
public boolean equals(TSOpenSessionResp that) {
if (that == null)
return false;
boolean this_present_status = true && this.isSetStatus();
boolean that_present_status = true && that.isSetStatus();
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (!this.status.equals(that.status))
return false;
}
boolean this_present_serverProtocolVersion = true && this.isSetServerProtocolVersion();
boolean that_present_serverProtocolVersion = true && that.isSetServerProtocolVersion();
if (this_present_serverProtocolVersion || that_present_serverProtocolVersion) {
if (!(this_present_serverProtocolVersion && that_present_serverProtocolVersion))
return false;
if (!this.serverProtocolVersion.equals(that.serverProtocolVersion))
return false;
}
boolean this_present_sessionHandle = true && this.isSetSessionHandle();
boolean that_present_sessionHandle = true && that.isSetSessionHandle();
if (this_present_sessionHandle || that_present_sessionHandle) {
if (!(this_present_sessionHandle && that_present_sessionHandle))
return false;
if (!this.sessionHandle.equals(that.sessionHandle))
return false;
}
boolean this_present_configuration = true && this.isSetConfiguration();
boolean that_present_configuration = true && that.isSetConfiguration();
if (this_present_configuration || that_present_configuration) {
if (!(this_present_configuration && that_present_configuration))
return false;
if (!this.configuration.equals(that.configuration))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_status = true && (isSetStatus());
list.add(present_status);
if (present_status)
list.add(status);
boolean present_serverProtocolVersion = true && (isSetServerProtocolVersion());
list.add(present_serverProtocolVersion);
if (present_serverProtocolVersion)
list.add(serverProtocolVersion.getValue());
boolean present_sessionHandle = true && (isSetSessionHandle());
list.add(present_sessionHandle);
if (present_sessionHandle)
list.add(sessionHandle);
boolean present_configuration = true && (isSetConfiguration());
list.add(present_configuration);
if (present_configuration)
list.add(configuration);
return list.hashCode();
}
@Override
public int compareTo(TSOpenSessionResp other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatus()).compareTo(other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetServerProtocolVersion()).compareTo(other.isSetServerProtocolVersion());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetServerProtocolVersion()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.serverProtocolVersion, other.serverProtocolVersion);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(other.isSetSessionHandle());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSessionHandle()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, other.sessionHandle);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetConfiguration()).compareTo(other.isSetConfiguration());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetConfiguration()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.configuration, other.configuration);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSOpenSessionResp(");
boolean first = true;
sb.append("status:");
if (this.status == null) {
sb.append("null");
} else {
sb.append(this.status);
}
first = false;
if (!first) sb.append(", ");
sb.append("serverProtocolVersion:");
if (this.serverProtocolVersion == null) {
sb.append("null");
} else {
sb.append(this.serverProtocolVersion);
}
first = false;
if (isSetSessionHandle()) {
if (!first) sb.append(", ");
sb.append("sessionHandle:");
if (this.sessionHandle == null) {
sb.append("null");
} else {
sb.append(this.sessionHandle);
}
first = false;
}
if (isSetConfiguration()) {
if (!first) sb.append(", ");
sb.append("configuration:");
if (this.configuration == null) {
sb.append("null");
} else {
sb.append(this.configuration);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (status == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'status' was not present! Struct: " + toString());
}
if (serverProtocolVersion == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'serverProtocolVersion' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSOpenSessionRespStandardSchemeFactory implements SchemeFactory {
public TSOpenSessionRespStandardScheme getScheme() {
return new TSOpenSessionRespStandardScheme();
}
}
private static class TSOpenSessionRespStandardScheme extends StandardScheme<TSOpenSessionResp> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSOpenSessionResp struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // SERVER_PROTOCOL_VERSION
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32());
struct.setServerProtocolVersionIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // SESSION_HANDLE
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // CONFIGURATION
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
org.apache.thrift.protocol.TMap _map10 = iprot.readMapBegin();
struct.configuration = new HashMap<String,String>(2*_map10.size);
String _key11;
String _val12;
for (int _i13 = 0; _i13 < _map10.size; ++_i13)
{
_key11 = iprot.readString();
_val12 = iprot.readString();
struct.configuration.put(_key11, _val12);
}
iprot.readMapEnd();
}
struct.setConfigurationIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSOpenSessionResp struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.status != null) {
oprot.writeFieldBegin(STATUS_FIELD_DESC);
struct.status.write(oprot);
oprot.writeFieldEnd();
}
if (struct.serverProtocolVersion != null) {
oprot.writeFieldBegin(SERVER_PROTOCOL_VERSION_FIELD_DESC);
oprot.writeI32(struct.serverProtocolVersion.getValue());
oprot.writeFieldEnd();
}
if (struct.sessionHandle != null) {
if (struct.isSetSessionHandle()) {
oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC);
struct.sessionHandle.write(oprot);
oprot.writeFieldEnd();
}
}
if (struct.configuration != null) {
if (struct.isSetConfiguration()) {
oprot.writeFieldBegin(CONFIGURATION_FIELD_DESC);
{
oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.configuration.size()));
for (Map.Entry<String, String> _iter14 : struct.configuration.entrySet())
{
oprot.writeString(_iter14.getKey());
oprot.writeString(_iter14.getValue());
}
oprot.writeMapEnd();
}
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSOpenSessionRespTupleSchemeFactory implements SchemeFactory {
public TSOpenSessionRespTupleScheme getScheme() {
return new TSOpenSessionRespTupleScheme();
}
}
private static class TSOpenSessionRespTupleScheme extends TupleScheme<TSOpenSessionResp> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionResp struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.status.write(oprot);
oprot.writeI32(struct.serverProtocolVersion.getValue());
BitSet optionals = new BitSet();
if (struct.isSetSessionHandle()) {
optionals.set(0);
}
if (struct.isSetConfiguration()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetSessionHandle()) {
struct.sessionHandle.write(oprot);
}
if (struct.isSetConfiguration()) {
{
oprot.writeI32(struct.configuration.size());
for (Map.Entry<String, String> _iter15 : struct.configuration.entrySet())
{
oprot.writeString(_iter15.getKey());
oprot.writeString(_iter15.getValue());
}
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSOpenSessionResp struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.status = new TS_Status();
struct.status.read(iprot);
struct.setStatusIsSet(true);
struct.serverProtocolVersion = cn.edu.thu.tsfiledb.service.rpc.thrift.TSProtocolVersion.findByValue(iprot.readI32());
struct.setServerProtocolVersionIsSet(true);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.sessionHandle = new TS_SessionHandle();
struct.sessionHandle.read(iprot);
struct.setSessionHandleIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TMap _map16 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.configuration = new HashMap<String,String>(2*_map16.size);
String _key17;
String _val18;
for (int _i19 = 0; _i19 < _map16.size; ++_i19)
{
_key17 = iprot.readString();
_val18 = iprot.readString();
struct.configuration.put(_key17, _val18);
}
}
struct.setConfigurationIsSet(true);
}
}
}
}

View File

@ -0,0 +1,496 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSOperationHandle implements org.apache.thrift.TBase<TSOperationHandle, TSOperationHandle._Fields>, java.io.Serializable, Cloneable, Comparable<TSOperationHandle> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSOperationHandle");
private static final org.apache.thrift.protocol.TField OPERATION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("operationId", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final org.apache.thrift.protocol.TField HAS_RESULT_SET_FIELD_DESC = new org.apache.thrift.protocol.TField("hasResultSet", org.apache.thrift.protocol.TType.BOOL, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSOperationHandleStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSOperationHandleTupleSchemeFactory());
}
public TSHandleIdentifier operationId; // required
public boolean hasResultSet; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
OPERATION_ID((short)1, "operationId"),
HAS_RESULT_SET((short)2, "hasResultSet");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // OPERATION_ID
return OPERATION_ID;
case 2: // HAS_RESULT_SET
return HAS_RESULT_SET;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __HASRESULTSET_ISSET_ID = 0;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.OPERATION_ID, new org.apache.thrift.meta_data.FieldMetaData("operationId", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSHandleIdentifier.class)));
tmpMap.put(_Fields.HAS_RESULT_SET, new org.apache.thrift.meta_data.FieldMetaData("hasResultSet", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSOperationHandle.class, metaDataMap);
}
public TSOperationHandle() {
}
public TSOperationHandle(
TSHandleIdentifier operationId,
boolean hasResultSet)
{
this();
this.operationId = operationId;
this.hasResultSet = hasResultSet;
setHasResultSetIsSet(true);
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSOperationHandle(TSOperationHandle other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetOperationId()) {
this.operationId = new TSHandleIdentifier(other.operationId);
}
this.hasResultSet = other.hasResultSet;
}
public TSOperationHandle deepCopy() {
return new TSOperationHandle(this);
}
@Override
public void clear() {
this.operationId = null;
setHasResultSetIsSet(false);
this.hasResultSet = false;
}
public TSHandleIdentifier getOperationId() {
return this.operationId;
}
public TSOperationHandle setOperationId(TSHandleIdentifier operationId) {
this.operationId = operationId;
return this;
}
public void unsetOperationId() {
this.operationId = null;
}
/** Returns true if field operationId is set (has been assigned a value) and false otherwise */
public boolean isSetOperationId() {
return this.operationId != null;
}
public void setOperationIdIsSet(boolean value) {
if (!value) {
this.operationId = null;
}
}
public boolean isHasResultSet() {
return this.hasResultSet;
}
public TSOperationHandle setHasResultSet(boolean hasResultSet) {
this.hasResultSet = hasResultSet;
setHasResultSetIsSet(true);
return this;
}
public void unsetHasResultSet() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __HASRESULTSET_ISSET_ID);
}
/** Returns true if field hasResultSet is set (has been assigned a value) and false otherwise */
public boolean isSetHasResultSet() {
return EncodingUtils.testBit(__isset_bitfield, __HASRESULTSET_ISSET_ID);
}
public void setHasResultSetIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __HASRESULTSET_ISSET_ID, value);
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case OPERATION_ID:
if (value == null) {
unsetOperationId();
} else {
setOperationId((TSHandleIdentifier)value);
}
break;
case HAS_RESULT_SET:
if (value == null) {
unsetHasResultSet();
} else {
setHasResultSet((Boolean)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case OPERATION_ID:
return getOperationId();
case HAS_RESULT_SET:
return Boolean.valueOf(isHasResultSet());
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case OPERATION_ID:
return isSetOperationId();
case HAS_RESULT_SET:
return isSetHasResultSet();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSOperationHandle)
return this.equals((TSOperationHandle)that);
return false;
}
public boolean equals(TSOperationHandle that) {
if (that == null)
return false;
boolean this_present_operationId = true && this.isSetOperationId();
boolean that_present_operationId = true && that.isSetOperationId();
if (this_present_operationId || that_present_operationId) {
if (!(this_present_operationId && that_present_operationId))
return false;
if (!this.operationId.equals(that.operationId))
return false;
}
boolean this_present_hasResultSet = true;
boolean that_present_hasResultSet = true;
if (this_present_hasResultSet || that_present_hasResultSet) {
if (!(this_present_hasResultSet && that_present_hasResultSet))
return false;
if (this.hasResultSet != that.hasResultSet)
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_operationId = true && (isSetOperationId());
list.add(present_operationId);
if (present_operationId)
list.add(operationId);
boolean present_hasResultSet = true;
list.add(present_hasResultSet);
if (present_hasResultSet)
list.add(hasResultSet);
return list.hashCode();
}
@Override
public int compareTo(TSOperationHandle other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetOperationId()).compareTo(other.isSetOperationId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetOperationId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.operationId, other.operationId);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetHasResultSet()).compareTo(other.isSetHasResultSet());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetHasResultSet()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.hasResultSet, other.hasResultSet);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSOperationHandle(");
boolean first = true;
sb.append("operationId:");
if (this.operationId == null) {
sb.append("null");
} else {
sb.append(this.operationId);
}
first = false;
if (!first) sb.append(", ");
sb.append("hasResultSet:");
sb.append(this.hasResultSet);
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (operationId == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'operationId' was not present! Struct: " + toString());
}
// alas, we cannot check 'hasResultSet' because it's a primitive and you chose the non-beans generator.
// check for sub-struct validity
if (operationId != null) {
operationId.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSOperationHandleStandardSchemeFactory implements SchemeFactory {
public TSOperationHandleStandardScheme getScheme() {
return new TSOperationHandleStandardScheme();
}
}
private static class TSOperationHandleStandardScheme extends StandardScheme<TSOperationHandle> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSOperationHandle struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // OPERATION_ID
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.operationId = new TSHandleIdentifier();
struct.operationId.read(iprot);
struct.setOperationIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // HAS_RESULT_SET
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.hasResultSet = iprot.readBool();
struct.setHasResultSetIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
if (!struct.isSetHasResultSet()) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'hasResultSet' was not found in serialized data! Struct: " + toString());
}
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSOperationHandle struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.operationId != null) {
oprot.writeFieldBegin(OPERATION_ID_FIELD_DESC);
struct.operationId.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(HAS_RESULT_SET_FIELD_DESC);
oprot.writeBool(struct.hasResultSet);
oprot.writeFieldEnd();
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSOperationHandleTupleSchemeFactory implements SchemeFactory {
public TSOperationHandleTupleScheme getScheme() {
return new TSOperationHandleTupleScheme();
}
}
private static class TSOperationHandleTupleScheme extends TupleScheme<TSOperationHandle> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSOperationHandle struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.operationId.write(oprot);
oprot.writeBool(struct.hasResultSet);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSOperationHandle struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.operationId = new TSHandleIdentifier();
struct.operationId.read(iprot);
struct.setOperationIdIsSet(true);
struct.hasResultSet = iprot.readBool();
struct.setHasResultSetIsSet(true);
}
}
}

View File

@ -0,0 +1,42 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
public enum TSProtocolVersion implements org.apache.thrift.TEnum {
TSFILE_SERVICE_PROTOCOL_V1(0);
private final int value;
private TSProtocolVersion(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static TSProtocolVersion findByValue(int value) {
switch (value) {
case 0:
return TSFILE_SERVICE_PROTOCOL_V1;
default:
return null;
}
}
}

View File

@ -0,0 +1,595 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TSQueryDataSet implements org.apache.thrift.TBase<TSQueryDataSet, TSQueryDataSet._Fields>, java.io.Serializable, Cloneable, Comparable<TSQueryDataSet> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TSQueryDataSet");
private static final org.apache.thrift.protocol.TField KEYS_FIELD_DESC = new org.apache.thrift.protocol.TField("keys", org.apache.thrift.protocol.TType.LIST, (short)1);
private static final org.apache.thrift.protocol.TField VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("values", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TSQueryDataSetStandardSchemeFactory());
schemes.put(TupleScheme.class, new TSQueryDataSetTupleSchemeFactory());
}
public List<String> keys; // required
public List<TSDynamicOneColumnData> values; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
KEYS((short)1, "keys"),
VALUES((short)2, "values");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // KEYS
return KEYS;
case 2: // VALUES
return VALUES;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.KEYS, new org.apache.thrift.meta_data.FieldMetaData("keys", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
tmpMap.put(_Fields.VALUES, new org.apache.thrift.meta_data.FieldMetaData("values", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT , "TSDynamicOneColumnData"))));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TSQueryDataSet.class, metaDataMap);
}
public TSQueryDataSet() {
}
public TSQueryDataSet(
List<String> keys,
List<TSDynamicOneColumnData> values)
{
this();
this.keys = keys;
this.values = values;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TSQueryDataSet(TSQueryDataSet other) {
if (other.isSetKeys()) {
List<String> __this__keys = new ArrayList<String>(other.keys);
this.keys = __this__keys;
}
if (other.isSetValues()) {
List<TSDynamicOneColumnData> __this__values = new ArrayList<TSDynamicOneColumnData>(other.values.size());
for (TSDynamicOneColumnData other_element : other.values) {
__this__values.add(other_element);
}
this.values = __this__values;
}
}
public TSQueryDataSet deepCopy() {
return new TSQueryDataSet(this);
}
@Override
public void clear() {
this.keys = null;
this.values = null;
}
public int getKeysSize() {
return (this.keys == null) ? 0 : this.keys.size();
}
public java.util.Iterator<String> getKeysIterator() {
return (this.keys == null) ? null : this.keys.iterator();
}
public void addToKeys(String elem) {
if (this.keys == null) {
this.keys = new ArrayList<String>();
}
this.keys.add(elem);
}
public List<String> getKeys() {
return this.keys;
}
public TSQueryDataSet setKeys(List<String> keys) {
this.keys = keys;
return this;
}
public void unsetKeys() {
this.keys = null;
}
/** Returns true if field keys is set (has been assigned a value) and false otherwise */
public boolean isSetKeys() {
return this.keys != null;
}
public void setKeysIsSet(boolean value) {
if (!value) {
this.keys = null;
}
}
public int getValuesSize() {
return (this.values == null) ? 0 : this.values.size();
}
public java.util.Iterator<TSDynamicOneColumnData> getValuesIterator() {
return (this.values == null) ? null : this.values.iterator();
}
public void addToValues(TSDynamicOneColumnData elem) {
if (this.values == null) {
this.values = new ArrayList<TSDynamicOneColumnData>();
}
this.values.add(elem);
}
public List<TSDynamicOneColumnData> getValues() {
return this.values;
}
public TSQueryDataSet setValues(List<TSDynamicOneColumnData> values) {
this.values = values;
return this;
}
public void unsetValues() {
this.values = null;
}
/** Returns true if field values is set (has been assigned a value) and false otherwise */
public boolean isSetValues() {
return this.values != null;
}
public void setValuesIsSet(boolean value) {
if (!value) {
this.values = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case KEYS:
if (value == null) {
unsetKeys();
} else {
setKeys((List<String>)value);
}
break;
case VALUES:
if (value == null) {
unsetValues();
} else {
setValues((List<TSDynamicOneColumnData>)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case KEYS:
return getKeys();
case VALUES:
return getValues();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case KEYS:
return isSetKeys();
case VALUES:
return isSetValues();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TSQueryDataSet)
return this.equals((TSQueryDataSet)that);
return false;
}
public boolean equals(TSQueryDataSet that) {
if (that == null)
return false;
boolean this_present_keys = true && this.isSetKeys();
boolean that_present_keys = true && that.isSetKeys();
if (this_present_keys || that_present_keys) {
if (!(this_present_keys && that_present_keys))
return false;
if (!this.keys.equals(that.keys))
return false;
}
boolean this_present_values = true && this.isSetValues();
boolean that_present_values = true && that.isSetValues();
if (this_present_values || that_present_values) {
if (!(this_present_values && that_present_values))
return false;
if (!this.values.equals(that.values))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_keys = true && (isSetKeys());
list.add(present_keys);
if (present_keys)
list.add(keys);
boolean present_values = true && (isSetValues());
list.add(present_values);
if (present_values)
list.add(values);
return list.hashCode();
}
@Override
public int compareTo(TSQueryDataSet other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetKeys()).compareTo(other.isSetKeys());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetKeys()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.keys, other.keys);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetValues()).compareTo(other.isSetValues());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetValues()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.values, other.values);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TSQueryDataSet(");
boolean first = true;
sb.append("keys:");
if (this.keys == null) {
sb.append("null");
} else {
sb.append(this.keys);
}
first = false;
if (!first) sb.append(", ");
sb.append("values:");
if (this.values == null) {
sb.append("null");
} else {
sb.append(this.values);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (keys == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'keys' was not present! Struct: " + toString());
}
if (values == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'values' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TSQueryDataSetStandardSchemeFactory implements SchemeFactory {
public TSQueryDataSetStandardScheme getScheme() {
return new TSQueryDataSetStandardScheme();
}
}
private static class TSQueryDataSetStandardScheme extends StandardScheme<TSQueryDataSet> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TSQueryDataSet struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // KEYS
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list52 = iprot.readListBegin();
struct.keys = new ArrayList<String>(_list52.size);
String _elem53;
for (int _i54 = 0; _i54 < _list52.size; ++_i54)
{
_elem53 = iprot.readString();
struct.keys.add(_elem53);
}
iprot.readListEnd();
}
struct.setKeysIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // VALUES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list55 = iprot.readListBegin();
struct.values = new ArrayList<TSDynamicOneColumnData>(_list55.size);
TSDynamicOneColumnData _elem56;
for (int _i57 = 0; _i57 < _list55.size; ++_i57)
{
_elem56 = new TSDynamicOneColumnData();
_elem56.read(iprot);
struct.values.add(_elem56);
}
iprot.readListEnd();
}
struct.setValuesIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TSQueryDataSet struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.keys != null) {
oprot.writeFieldBegin(KEYS_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.keys.size()));
for (String _iter58 : struct.keys)
{
oprot.writeString(_iter58);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
if (struct.values != null) {
oprot.writeFieldBegin(VALUES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.values.size()));
for (TSDynamicOneColumnData _iter59 : struct.values)
{
_iter59.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TSQueryDataSetTupleSchemeFactory implements SchemeFactory {
public TSQueryDataSetTupleScheme getScheme() {
return new TSQueryDataSetTupleScheme();
}
}
private static class TSQueryDataSetTupleScheme extends TupleScheme<TSQueryDataSet> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TSQueryDataSet struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
{
oprot.writeI32(struct.keys.size());
for (String _iter60 : struct.keys)
{
oprot.writeString(_iter60);
}
}
{
oprot.writeI32(struct.values.size());
for (TSDynamicOneColumnData _iter61 : struct.values)
{
_iter61.write(oprot);
}
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TSQueryDataSet struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
{
org.apache.thrift.protocol.TList _list62 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.keys = new ArrayList<String>(_list62.size);
String _elem63;
for (int _i64 = 0; _i64 < _list62.size; ++_i64)
{
_elem63 = iprot.readString();
struct.keys.add(_elem63);
}
}
struct.setKeysIsSet(true);
{
org.apache.thrift.protocol.TList _list65 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.values = new ArrayList<TSDynamicOneColumnData>(_list65.size);
TSDynamicOneColumnData _elem66;
for (int _i67 = 0; _i67 < _list65.size; ++_i67)
{
_elem66 = new TSDynamicOneColumnData();
_elem66.read(iprot);
struct.values.add(_elem66);
}
}
struct.setValuesIsSet(true);
}
}
}

View File

@ -0,0 +1,396 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TS_SessionHandle implements org.apache.thrift.TBase<TS_SessionHandle, TS_SessionHandle._Fields>, java.io.Serializable, Cloneable, Comparable<TS_SessionHandle> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TS_SessionHandle");
private static final org.apache.thrift.protocol.TField SESSION_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionId", org.apache.thrift.protocol.TType.STRUCT, (short)1);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TS_SessionHandleStandardSchemeFactory());
schemes.put(TupleScheme.class, new TS_SessionHandleTupleSchemeFactory());
}
public TSHandleIdentifier sessionId; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
SESSION_ID((short)1, "sessionId");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // SESSION_ID
return SESSION_ID;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.SESSION_ID, new org.apache.thrift.meta_data.FieldMetaData("sessionId", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSHandleIdentifier.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TS_SessionHandle.class, metaDataMap);
}
public TS_SessionHandle() {
}
public TS_SessionHandle(
TSHandleIdentifier sessionId)
{
this();
this.sessionId = sessionId;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TS_SessionHandle(TS_SessionHandle other) {
if (other.isSetSessionId()) {
this.sessionId = new TSHandleIdentifier(other.sessionId);
}
}
public TS_SessionHandle deepCopy() {
return new TS_SessionHandle(this);
}
@Override
public void clear() {
this.sessionId = null;
}
public TSHandleIdentifier getSessionId() {
return this.sessionId;
}
public TS_SessionHandle setSessionId(TSHandleIdentifier sessionId) {
this.sessionId = sessionId;
return this;
}
public void unsetSessionId() {
this.sessionId = null;
}
/** Returns true if field sessionId is set (has been assigned a value) and false otherwise */
public boolean isSetSessionId() {
return this.sessionId != null;
}
public void setSessionIdIsSet(boolean value) {
if (!value) {
this.sessionId = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case SESSION_ID:
if (value == null) {
unsetSessionId();
} else {
setSessionId((TSHandleIdentifier)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case SESSION_ID:
return getSessionId();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case SESSION_ID:
return isSetSessionId();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TS_SessionHandle)
return this.equals((TS_SessionHandle)that);
return false;
}
public boolean equals(TS_SessionHandle that) {
if (that == null)
return false;
boolean this_present_sessionId = true && this.isSetSessionId();
boolean that_present_sessionId = true && that.isSetSessionId();
if (this_present_sessionId || that_present_sessionId) {
if (!(this_present_sessionId && that_present_sessionId))
return false;
if (!this.sessionId.equals(that.sessionId))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_sessionId = true && (isSetSessionId());
list.add(present_sessionId);
if (present_sessionId)
list.add(sessionId);
return list.hashCode();
}
@Override
public int compareTo(TS_SessionHandle other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetSessionId()).compareTo(other.isSetSessionId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSessionId()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionId, other.sessionId);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TS_SessionHandle(");
boolean first = true;
sb.append("sessionId:");
if (this.sessionId == null) {
sb.append("null");
} else {
sb.append(this.sessionId);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (sessionId == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionId' was not present! Struct: " + toString());
}
// check for sub-struct validity
if (sessionId != null) {
sessionId.validate();
}
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TS_SessionHandleStandardSchemeFactory implements SchemeFactory {
public TS_SessionHandleStandardScheme getScheme() {
return new TS_SessionHandleStandardScheme();
}
}
private static class TS_SessionHandleStandardScheme extends StandardScheme<TS_SessionHandle> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TS_SessionHandle struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // SESSION_ID
if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
struct.sessionId = new TSHandleIdentifier();
struct.sessionId.read(iprot);
struct.setSessionIdIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TS_SessionHandle struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.sessionId != null) {
oprot.writeFieldBegin(SESSION_ID_FIELD_DESC);
struct.sessionId.write(oprot);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TS_SessionHandleTupleSchemeFactory implements SchemeFactory {
public TS_SessionHandleTupleScheme getScheme() {
return new TS_SessionHandleTupleScheme();
}
}
private static class TS_SessionHandleTupleScheme extends TupleScheme<TS_SessionHandle> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TS_SessionHandle struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
struct.sessionId.write(oprot);
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TS_SessionHandle struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.sessionId = new TSHandleIdentifier();
struct.sessionId.read(iprot);
struct.setSessionIdIsSet(true);
}
}
}

View File

@ -0,0 +1,885 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import javax.annotation.Generated;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
@Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2017-5-10")
public class TS_Status implements org.apache.thrift.TBase<TS_Status, TS_Status._Fields>, java.io.Serializable, Cloneable, Comparable<TS_Status> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TS_Status");
private static final org.apache.thrift.protocol.TField STATUS_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("statusCode", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField INFO_MESSAGES_FIELD_DESC = new org.apache.thrift.protocol.TField("infoMessages", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField SQL_STATE_FIELD_DESC = new org.apache.thrift.protocol.TField("sqlState", org.apache.thrift.protocol.TType.STRING, (short)3);
private static final org.apache.thrift.protocol.TField ERROR_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("errorCode", org.apache.thrift.protocol.TType.I32, (short)4);
private static final org.apache.thrift.protocol.TField ERROR_MESSAGE_FIELD_DESC = new org.apache.thrift.protocol.TField("errorMessage", org.apache.thrift.protocol.TType.STRING, (short)5);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new TS_StatusStandardSchemeFactory());
schemes.put(TupleScheme.class, new TS_StatusTupleSchemeFactory());
}
/**
*
* @see TS_StatusCode
*/
public TS_StatusCode statusCode; // required
public List<String> infoMessages; // optional
public String sqlState; // optional
public int errorCode; // optional
public String errorMessage; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
/**
*
* @see TS_StatusCode
*/
STATUS_CODE((short)1, "statusCode"),
INFO_MESSAGES((short)2, "infoMessages"),
SQL_STATE((short)3, "sqlState"),
ERROR_CODE((short)4, "errorCode"),
ERROR_MESSAGE((short)5, "errorMessage");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // STATUS_CODE
return STATUS_CODE;
case 2: // INFO_MESSAGES
return INFO_MESSAGES;
case 3: // SQL_STATE
return SQL_STATE;
case 4: // ERROR_CODE
return ERROR_CODE;
case 5: // ERROR_MESSAGE
return ERROR_MESSAGE;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __ERRORCODE_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private static final _Fields optionals[] = {_Fields.INFO_MESSAGES,_Fields.SQL_STATE,_Fields.ERROR_CODE,_Fields.ERROR_MESSAGE};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.STATUS_CODE, new org.apache.thrift.meta_data.FieldMetaData("statusCode", org.apache.thrift.TFieldRequirementType.REQUIRED,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TS_StatusCode.class)));
tmpMap.put(_Fields.INFO_MESSAGES, new org.apache.thrift.meta_data.FieldMetaData("infoMessages", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))));
tmpMap.put(_Fields.SQL_STATE, new org.apache.thrift.meta_data.FieldMetaData("sqlState", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.ERROR_CODE, new org.apache.thrift.meta_data.FieldMetaData("errorCode", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.ERROR_MESSAGE, new org.apache.thrift.meta_data.FieldMetaData("errorMessage", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TS_Status.class, metaDataMap);
}
public TS_Status() {
}
public TS_Status(
TS_StatusCode statusCode)
{
this();
this.statusCode = statusCode;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TS_Status(TS_Status other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetStatusCode()) {
this.statusCode = other.statusCode;
}
if (other.isSetInfoMessages()) {
List<String> __this__infoMessages = new ArrayList<String>(other.infoMessages);
this.infoMessages = __this__infoMessages;
}
if (other.isSetSqlState()) {
this.sqlState = other.sqlState;
}
this.errorCode = other.errorCode;
if (other.isSetErrorMessage()) {
this.errorMessage = other.errorMessage;
}
}
public TS_Status deepCopy() {
return new TS_Status(this);
}
@Override
public void clear() {
this.statusCode = null;
this.infoMessages = null;
this.sqlState = null;
setErrorCodeIsSet(false);
this.errorCode = 0;
this.errorMessage = null;
}
/**
*
* @see TS_StatusCode
*/
public TS_StatusCode getStatusCode() {
return this.statusCode;
}
/**
*
* @see TS_StatusCode
*/
public TS_Status setStatusCode(TS_StatusCode statusCode) {
this.statusCode = statusCode;
return this;
}
public void unsetStatusCode() {
this.statusCode = null;
}
/** Returns true if field statusCode is set (has been assigned a value) and false otherwise */
public boolean isSetStatusCode() {
return this.statusCode != null;
}
public void setStatusCodeIsSet(boolean value) {
if (!value) {
this.statusCode = null;
}
}
public int getInfoMessagesSize() {
return (this.infoMessages == null) ? 0 : this.infoMessages.size();
}
public java.util.Iterator<String> getInfoMessagesIterator() {
return (this.infoMessages == null) ? null : this.infoMessages.iterator();
}
public void addToInfoMessages(String elem) {
if (this.infoMessages == null) {
this.infoMessages = new ArrayList<String>();
}
this.infoMessages.add(elem);
}
public List<String> getInfoMessages() {
return this.infoMessages;
}
public TS_Status setInfoMessages(List<String> infoMessages) {
this.infoMessages = infoMessages;
return this;
}
public void unsetInfoMessages() {
this.infoMessages = null;
}
/** Returns true if field infoMessages is set (has been assigned a value) and false otherwise */
public boolean isSetInfoMessages() {
return this.infoMessages != null;
}
public void setInfoMessagesIsSet(boolean value) {
if (!value) {
this.infoMessages = null;
}
}
public String getSqlState() {
return this.sqlState;
}
public TS_Status setSqlState(String sqlState) {
this.sqlState = sqlState;
return this;
}
public void unsetSqlState() {
this.sqlState = null;
}
/** Returns true if field sqlState is set (has been assigned a value) and false otherwise */
public boolean isSetSqlState() {
return this.sqlState != null;
}
public void setSqlStateIsSet(boolean value) {
if (!value) {
this.sqlState = null;
}
}
public int getErrorCode() {
return this.errorCode;
}
public TS_Status setErrorCode(int errorCode) {
this.errorCode = errorCode;
setErrorCodeIsSet(true);
return this;
}
public void unsetErrorCode() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ERRORCODE_ISSET_ID);
}
/** Returns true if field errorCode is set (has been assigned a value) and false otherwise */
public boolean isSetErrorCode() {
return EncodingUtils.testBit(__isset_bitfield, __ERRORCODE_ISSET_ID);
}
public void setErrorCodeIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ERRORCODE_ISSET_ID, value);
}
public String getErrorMessage() {
return this.errorMessage;
}
public TS_Status setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
return this;
}
public void unsetErrorMessage() {
this.errorMessage = null;
}
/** Returns true if field errorMessage is set (has been assigned a value) and false otherwise */
public boolean isSetErrorMessage() {
return this.errorMessage != null;
}
public void setErrorMessageIsSet(boolean value) {
if (!value) {
this.errorMessage = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case STATUS_CODE:
if (value == null) {
unsetStatusCode();
} else {
setStatusCode((TS_StatusCode)value);
}
break;
case INFO_MESSAGES:
if (value == null) {
unsetInfoMessages();
} else {
setInfoMessages((List<String>)value);
}
break;
case SQL_STATE:
if (value == null) {
unsetSqlState();
} else {
setSqlState((String)value);
}
break;
case ERROR_CODE:
if (value == null) {
unsetErrorCode();
} else {
setErrorCode((Integer)value);
}
break;
case ERROR_MESSAGE:
if (value == null) {
unsetErrorMessage();
} else {
setErrorMessage((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case STATUS_CODE:
return getStatusCode();
case INFO_MESSAGES:
return getInfoMessages();
case SQL_STATE:
return getSqlState();
case ERROR_CODE:
return Integer.valueOf(getErrorCode());
case ERROR_MESSAGE:
return getErrorMessage();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case STATUS_CODE:
return isSetStatusCode();
case INFO_MESSAGES:
return isSetInfoMessages();
case SQL_STATE:
return isSetSqlState();
case ERROR_CODE:
return isSetErrorCode();
case ERROR_MESSAGE:
return isSetErrorMessage();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TS_Status)
return this.equals((TS_Status)that);
return false;
}
public boolean equals(TS_Status that) {
if (that == null)
return false;
boolean this_present_statusCode = true && this.isSetStatusCode();
boolean that_present_statusCode = true && that.isSetStatusCode();
if (this_present_statusCode || that_present_statusCode) {
if (!(this_present_statusCode && that_present_statusCode))
return false;
if (!this.statusCode.equals(that.statusCode))
return false;
}
boolean this_present_infoMessages = true && this.isSetInfoMessages();
boolean that_present_infoMessages = true && that.isSetInfoMessages();
if (this_present_infoMessages || that_present_infoMessages) {
if (!(this_present_infoMessages && that_present_infoMessages))
return false;
if (!this.infoMessages.equals(that.infoMessages))
return false;
}
boolean this_present_sqlState = true && this.isSetSqlState();
boolean that_present_sqlState = true && that.isSetSqlState();
if (this_present_sqlState || that_present_sqlState) {
if (!(this_present_sqlState && that_present_sqlState))
return false;
if (!this.sqlState.equals(that.sqlState))
return false;
}
boolean this_present_errorCode = true && this.isSetErrorCode();
boolean that_present_errorCode = true && that.isSetErrorCode();
if (this_present_errorCode || that_present_errorCode) {
if (!(this_present_errorCode && that_present_errorCode))
return false;
if (this.errorCode != that.errorCode)
return false;
}
boolean this_present_errorMessage = true && this.isSetErrorMessage();
boolean that_present_errorMessage = true && that.isSetErrorMessage();
if (this_present_errorMessage || that_present_errorMessage) {
if (!(this_present_errorMessage && that_present_errorMessage))
return false;
if (!this.errorMessage.equals(that.errorMessage))
return false;
}
return true;
}
@Override
public int hashCode() {
List<Object> list = new ArrayList<Object>();
boolean present_statusCode = true && (isSetStatusCode());
list.add(present_statusCode);
if (present_statusCode)
list.add(statusCode.getValue());
boolean present_infoMessages = true && (isSetInfoMessages());
list.add(present_infoMessages);
if (present_infoMessages)
list.add(infoMessages);
boolean present_sqlState = true && (isSetSqlState());
list.add(present_sqlState);
if (present_sqlState)
list.add(sqlState);
boolean present_errorCode = true && (isSetErrorCode());
list.add(present_errorCode);
if (present_errorCode)
list.add(errorCode);
boolean present_errorMessage = true && (isSetErrorMessage());
list.add(present_errorMessage);
if (present_errorMessage)
list.add(errorMessage);
return list.hashCode();
}
@Override
public int compareTo(TS_Status other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStatusCode()).compareTo(other.isSetStatusCode());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatusCode()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.statusCode, other.statusCode);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetInfoMessages()).compareTo(other.isSetInfoMessages());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetInfoMessages()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.infoMessages, other.infoMessages);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetSqlState()).compareTo(other.isSetSqlState());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetSqlState()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sqlState, other.sqlState);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetErrorCode()).compareTo(other.isSetErrorCode());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetErrorCode()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorCode, other.errorCode);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetErrorMessage()).compareTo(other.isSetErrorMessage());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetErrorMessage()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.errorMessage, other.errorMessage);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("TS_Status(");
boolean first = true;
sb.append("statusCode:");
if (this.statusCode == null) {
sb.append("null");
} else {
sb.append(this.statusCode);
}
first = false;
if (isSetInfoMessages()) {
if (!first) sb.append(", ");
sb.append("infoMessages:");
if (this.infoMessages == null) {
sb.append("null");
} else {
sb.append(this.infoMessages);
}
first = false;
}
if (isSetSqlState()) {
if (!first) sb.append(", ");
sb.append("sqlState:");
if (this.sqlState == null) {
sb.append("null");
} else {
sb.append(this.sqlState);
}
first = false;
}
if (isSetErrorCode()) {
if (!first) sb.append(", ");
sb.append("errorCode:");
sb.append(this.errorCode);
first = false;
}
if (isSetErrorMessage()) {
if (!first) sb.append(", ");
sb.append("errorMessage:");
if (this.errorMessage == null) {
sb.append("null");
} else {
sb.append(this.errorMessage);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
if (statusCode == null) {
throw new org.apache.thrift.protocol.TProtocolException("Required field 'statusCode' was not present! Struct: " + toString());
}
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
__isset_bitfield = 0;
read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private static class TS_StatusStandardSchemeFactory implements SchemeFactory {
public TS_StatusStandardScheme getScheme() {
return new TS_StatusStandardScheme();
}
}
private static class TS_StatusStandardScheme extends StandardScheme<TS_Status> {
public void read(org.apache.thrift.protocol.TProtocol iprot, TS_Status struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // STATUS_CODE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.statusCode = cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode.findByValue(iprot.readI32());
struct.setStatusCodeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // INFO_MESSAGES
if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
{
org.apache.thrift.protocol.TList _list20 = iprot.readListBegin();
struct.infoMessages = new ArrayList<String>(_list20.size);
String _elem21;
for (int _i22 = 0; _i22 < _list20.size; ++_i22)
{
_elem21 = iprot.readString();
struct.infoMessages.add(_elem21);
}
iprot.readListEnd();
}
struct.setInfoMessagesIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // SQL_STATE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.sqlState = iprot.readString();
struct.setSqlStateIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // ERROR_CODE
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.errorCode = iprot.readI32();
struct.setErrorCodeIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // ERROR_MESSAGE
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.errorMessage = iprot.readString();
struct.setErrorMessageIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, TS_Status struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.statusCode != null) {
oprot.writeFieldBegin(STATUS_CODE_FIELD_DESC);
oprot.writeI32(struct.statusCode.getValue());
oprot.writeFieldEnd();
}
if (struct.infoMessages != null) {
if (struct.isSetInfoMessages()) {
oprot.writeFieldBegin(INFO_MESSAGES_FIELD_DESC);
{
oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.infoMessages.size()));
for (String _iter23 : struct.infoMessages)
{
oprot.writeString(_iter23);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
}
if (struct.sqlState != null) {
if (struct.isSetSqlState()) {
oprot.writeFieldBegin(SQL_STATE_FIELD_DESC);
oprot.writeString(struct.sqlState);
oprot.writeFieldEnd();
}
}
if (struct.isSetErrorCode()) {
oprot.writeFieldBegin(ERROR_CODE_FIELD_DESC);
oprot.writeI32(struct.errorCode);
oprot.writeFieldEnd();
}
if (struct.errorMessage != null) {
if (struct.isSetErrorMessage()) {
oprot.writeFieldBegin(ERROR_MESSAGE_FIELD_DESC);
oprot.writeString(struct.errorMessage);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class TS_StatusTupleSchemeFactory implements SchemeFactory {
public TS_StatusTupleScheme getScheme() {
return new TS_StatusTupleScheme();
}
}
private static class TS_StatusTupleScheme extends TupleScheme<TS_Status> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, TS_Status struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
oprot.writeI32(struct.statusCode.getValue());
BitSet optionals = new BitSet();
if (struct.isSetInfoMessages()) {
optionals.set(0);
}
if (struct.isSetSqlState()) {
optionals.set(1);
}
if (struct.isSetErrorCode()) {
optionals.set(2);
}
if (struct.isSetErrorMessage()) {
optionals.set(3);
}
oprot.writeBitSet(optionals, 4);
if (struct.isSetInfoMessages()) {
{
oprot.writeI32(struct.infoMessages.size());
for (String _iter24 : struct.infoMessages)
{
oprot.writeString(_iter24);
}
}
}
if (struct.isSetSqlState()) {
oprot.writeString(struct.sqlState);
}
if (struct.isSetErrorCode()) {
oprot.writeI32(struct.errorCode);
}
if (struct.isSetErrorMessage()) {
oprot.writeString(struct.errorMessage);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, TS_Status struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
struct.statusCode = cn.edu.thu.tsfiledb.service.rpc.thrift.TS_StatusCode.findByValue(iprot.readI32());
struct.setStatusCodeIsSet(true);
BitSet incoming = iprot.readBitSet(4);
if (incoming.get(0)) {
{
org.apache.thrift.protocol.TList _list25 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.infoMessages = new ArrayList<String>(_list25.size);
String _elem26;
for (int _i27 = 0; _i27 < _list25.size; ++_i27)
{
_elem26 = iprot.readString();
struct.infoMessages.add(_elem26);
}
}
struct.setInfoMessagesIsSet(true);
}
if (incoming.get(1)) {
struct.sqlState = iprot.readString();
struct.setSqlStateIsSet(true);
}
if (incoming.get(2)) {
struct.errorCode = iprot.readI32();
struct.setErrorCodeIsSet(true);
}
if (incoming.get(3)) {
struct.errorMessage = iprot.readString();
struct.setErrorMessageIsSet(true);
}
}
}
}

View File

@ -0,0 +1,54 @@
/**
* Autogenerated by Thrift Compiler (0.9.2)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package cn.edu.thu.tsfiledb.service.rpc.thrift;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
public enum TS_StatusCode implements org.apache.thrift.TEnum {
SUCCESS_STATUS(0),
SUCCESS_WITH_INFO_STATUS(1),
STILL_EXECUTING_STATUS(2),
ERROR_STATUS(3),
INVALID_HANDLE_STATUS(4);
private final int value;
private TS_StatusCode(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static TS_StatusCode findByValue(int value) {
switch (value) {
case 0:
return SUCCESS_STATUS;
case 1:
return SUCCESS_WITH_INFO_STATUS;
case 2:
return STILL_EXECUTING_STATUS;
case 3:
return ERROR_STATUS;
case 4:
return INVALID_HANDLE_STATUS;
default:
return null;
}
}
}

View File

@ -0,0 +1,326 @@
namespace java cn.edu.thu.tsfiledb.service.rpc.thrift
service TSIService {
TSOpenSessionResp OpenSession(1:TSOpenSessionReq req);
TSCloseSessionResp CloseSession(1:TSCloseSessionReq req);
TSExecuteStatementResp ExecuteStatement(1:TSExecuteStatementReq req);
TSExecuteBatchStatementResp ExecuteBatchStatement(1:TSExecuteBatchStatementReq req);
TSExecuteStatementResp ExecuteQueryStatement(1:TSExecuteStatementReq req);
TSExecuteStatementResp ExecuteUpdateStatement(1:TSExecuteStatementReq req);
TSFetchResultsResp FetchResults(1:TSFetchResultsReq req)
TSFetchMetadataResp FetchMetadata(1:TSFetchMetadataReq req)
//TSGetOperationStatusResp GetOperationStatus(1:TSGetOperationStatusReq req);
TSCancelOperationResp CancelOperation(1:TSCancelOperationReq req);
TSCloseOperationResp CloseOperation(1:TSCloseOperationReq req);
//TSGetResultSetMetadataResp GetResultSetMetadata(1:TSGetResultSetMetadataReq req);
//TSFetchResultsResp FetchResults(1:TSFetchResultsReq req);
}
enum TSProtocolVersion {
TSFILE_SERVICE_PROTOCOL_V1,
}
// OpenSession()
//
// Open a session (connection) on the server against
// which operations may be executed.
struct TSOpenSessionReq {
1: required TSProtocolVersion client_protocol = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1
2: optional string username
3: optional string password
4: optional map<string, string> configuration
}
struct TSOpenSessionResp {
1: required TS_Status status
// The protocol version that the server is using.
2: required TSProtocolVersion serverProtocolVersion = TSProtocolVersion.TSFILE_SERVICE_PROTOCOL_V1
// Session Handle
3: optional TS_SessionHandle sessionHandle
// The configuration settings for this session.
4: optional map<string, string> configuration
}
// The return status code contained in each response.
enum TS_StatusCode {
SUCCESS_STATUS,
SUCCESS_WITH_INFO_STATUS,
STILL_EXECUTING_STATUS,
ERROR_STATUS,
INVALID_HANDLE_STATUS
}
// The return status of a remote request
struct TS_Status {
1: required TS_StatusCode statusCode
// If status is SUCCESS_WITH_INFO, info_msgs may be populated with
// additional diagnostic information.
2: optional list<string> infoMessages
// If status is ERROR, then the following fields may be set
3: optional string sqlState // as defined in the ISO/IEF CLI specification
4: optional i32 errorCode // internal error code
5: optional string errorMessage
}
// CloseSession()
//
// Closes the specified session and frees any resources
// currently allocated to that session. Any open
// operations in that session will be canceled.
struct TSCloseSessionReq {
1: required TS_SessionHandle sessionHandle
}
struct TSCloseSessionResp {
1: required TS_Status status
}
struct TSHandleIdentifier {
// 16 byte globally unique identifier
// This is the public ID of the handle and
// can be used for reporting.
1: required binary guid,
// 16 byte secret generated by the server
// and used to verify that the handle is not
// being hijacked by another user.
2: required binary secret,
}
// Client-side handle to persistent
// session information on the server-side.
struct TS_SessionHandle {
1: required TSHandleIdentifier sessionId
}
struct TSGetOperationStatusReq {
// Session to run this request against
1: required TSOperationHandle operationHandle
}
struct TSGetOperationStatusResp {
1: required TS_Status status
//2: optional TSOperationState operationState
// If operationState is ERROR_STATE, then the following fields may be set
// sqlState as defined in the ISO/IEF CLI specification
//3: optional string sqlState
// Internal error code
//4: optional i32 errorCode
// Error message
//5: optional string errorMessage
// List of statuses of sub tasks
//6: optional string taskStatus
// When was the operation started
//7: optional i64 operationStarted
// When was the operation completed
//8: optional i64 operationCompleted
// If the operation has the result
//9: optional bool hasResultSet
}
// CancelOperation()
//
// Cancels processing on the specified operation handle and
// frees any resources which were allocated.
struct TSCancelOperationReq {
// Operation to cancel
1: required TSOperationHandle operationHandle
}
struct TSCancelOperationResp {
1: required TS_Status status
}
// CloseOperation()
//
// Given an operation in the FINISHED, CANCELED,
// or ERROR states, CloseOperation() will free
// all of the resources which were allocated on
// the server to service the operation.
struct TSCloseOperationReq {
1: required TSOperationHandle operationHandle
}
struct TSCloseOperationResp {
1: required TS_Status status
}
// Client-side reference to a task running
// asynchronously on the server.
struct TSOperationHandle {
1: required TSHandleIdentifier operationId
// If hasResultSet = TRUE, then this operation
// generates a result set that can be fetched.
// Note that the result set may be empty.
//
// If hasResultSet = FALSE, then this operation
// does not generate a result set, and calling
// GetResultSetMetadata or FetchResults against
// this OperationHandle will generate an error.
2: required bool hasResultSet
//3: required TSOperationType operationType
// For operations that don't generate result sets,
// modifiedRowCount is either:
//
// 1) The number of rows that were modified by
// the DML operation (e.g. number of rows inserted,
// number of rows deleted, etc).
//
// 2) 0 for operations that don't modify or add rows.
//
// 3) < 0 if the operation is capable of modifiying rows,
// but Hive is unable to determine how many rows were
// modified. For example, Hive's LOAD DATA command
// doesn't generate row count information because
// Hive doesn't inspect the data as it is loaded.
//
// modifiedRowCount is unset if the operation generates
// a result set.
//4: optional double modifiedRowCount
}
// ExecuteStatement()
//
// Execute a statement.
// The returned OperationHandle can be used to check on the
// status of the statement, and to fetch results once the
// statement has finished executing.
struct TSExecuteStatementReq {
// The session to execute the statement against
1: required TS_SessionHandle sessionHandle
// The statement to be executed (DML, DDL, SET, etc)
2: required string statement
// Configuration properties that are overlayed on top of the
// the existing session configuration before this statement
// is executed. These properties apply to this statement
// only and will not affect the subsequent state of the Session.
//3: optional map<string, string> confOverlay
// Execute asynchronously when runAsync is true
//4: optional bool runAsync = false
// The number of seconds after which the query will timeout on the server
//5: optional i64 queryTimeout = 0
}
struct TSExecuteStatementResp {
1: required TS_Status status
2: optional TSOperationHandle operationHandle
3: optional list<string> columns
}
struct TSExecuteBatchStatementResp{
1: required TS_Status status
2: optional list<i32> result
}
struct TSExecuteBatchStatementReq{
// The session to execute the statement against
1: required TS_SessionHandle sessionHandle
// The statements to be executed (DML, DDL, SET, etc)
2: required list<string> statements
}
struct TSQueryDataSet{
1: required list<string> keys
2: required list<TSDynamicOneColumnData> values
}
struct TSDynamicOneColumnData{
1: required string deviceType
2: required string dataType
3: required i32 length
4: required list<i64> timeRet
5: optional list<bool> boolList
6: optional list<i32> i32List
7: optional list<i64> i64List
8: optional list<double> floatList
9: optional list<double> doubleList
10: optional list<byte> binaryList
}
struct TSFetchResultsReq{
1: required string statement
2: required i32 fetch_size
}
struct TSFetchResultsResp{
1: required TS_Status status
2: required bool hasResultSet
3: optional TSQueryDataSet queryDataSet
}
//
// struct TSJDBCRecord {
// 1: required string deviceType
// 2: required string deviceId
// 3: required list<TSDataPoint> dataList
// 4: required TSTimeValue timeValue
// }
//
// struct TSTimeValue {
// 1: required i64 time
// }
//
// struct TSDataPoint{
// 1: required string type
// 2: required string sensorId
// 3: required string deviceId
// 4: required string valueStr
// 5: optional i32 groupId
// }
struct TSFetchMetadataResp{
1: required TS_Status status
2: optional map<string, list<TSColumnSchema>> seriesMap
3: optional map<string, list<string>> deltaObjectMap
4: optional string metadataInJson
}
struct TSFetchMetadataReq{
}
struct TSColumnSchema{
1: optional string name;
2: optional string dataType;
3: optional string encoding;
4: optional map<string, string> otherArgs;
}

View File

@ -0,0 +1,236 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.assertEquals;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.AuthDao;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.RoleDao;
import cn.edu.thu.tsfiledb.auth.dao.UserDao;
import cn.edu.thu.tsfiledb.auth.model.Permission;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.RolePermission;
import cn.edu.thu.tsfiledb.auth.model.User;
import cn.edu.thu.tsfiledb.auth.model.UserPermission;
public class AuthTest {
private DBdao dbDao = null;
private Statement statement = null;
private AuthDao authDao = null;
// prepare the data
private User user1;
private User user2;
private Role role1;
private Role role2;
@Before
public void setUp() throws Exception {
dbDao = new DBdao();
authDao = new AuthDao();
dbDao.open();
statement = dbDao.getStatement();
// init data
user1 = new User("user1", "user1");
user2 = new User("user2", "user2");
role1 = new Role("role1");
role2 = new Role("role2");
}
@After
public void tearDown() throws Exception {
dbDao.close();
}
@Test
public void testUser() {
authDao.deleteUser(statement, user1.getUserName());
// add user
assertEquals(true, authDao.addUser(statement, user1));
// check the user inserted
UserDao userDao = new UserDao();
User user = userDao.getUser(statement, user1.getUserName());
assertEquals(user1.getUserName(), user.getUserName());
assertEquals(user1.getPassWord(), user.getPassWord());
// delete the user
assertEquals(true, authDao.deleteUser(statement, user1.getUserName()));
assertEquals(null, userDao.getUser(statement, user1.getUserName()));
authDao.addUser(statement, user1);
authDao.addUser(statement, user2);
// add the root user
assertEquals(3, authDao.getUsers(statement).size());
authDao.deleteUser(statement, user1.getUserName());
authDao.deleteUser(statement, user2.getUserName());
}
@Test
public void testRole() {
authDao.deleteRole(statement, role1.getRoleName());
// add role
assertEquals(true, authDao.addRole(statement, role1));
// check the role inserted
RoleDao roleDao = new RoleDao();
Role role = roleDao.getRole(statement, role1.getRoleName());
assertEquals(role1.getRoleName(), role.getRoleName());
// delete the role
assertEquals(true, authDao.deleteRole(statement, role1.getRoleName()));
assertEquals(null, roleDao.getRole(statement, role1.getRoleName()));
authDao.addRole(statement, role1);
authDao.addRole(statement, role2);
assertEquals(2, authDao.getRoles(statement).size());
authDao.deleteRole(statement, role1.getRoleName());
authDao.deleteRole(statement, role2.getRoleName());
}
@Test
public void testUserRoleRel() {
// add user and role
authDao.addUser(statement, user1);
authDao.addUser(statement, user2);
authDao.addRole(statement, role1);
authDao.addRole(statement, role2);
// add relation
assertEquals(true, authDao.addUserRoleRel(statement, user1.getUserName(), role1.getRoleName()));
assertEquals(1, authDao.getAllUserRoleRel(statement).size());
assertEquals(true, authDao.addUserRoleRel(statement, user1.getUserName(), role2.getRoleName()));
List<Role> roles = authDao.getRolesByUser(statement, user1.getUserName());
assertEquals(2, roles.size());
for (Role role : roles) {
assertEquals(true, (role.getRoleName().equals(role1.getRoleName()))
|| (role.getRoleName().equals(role2.getRoleName())));
}
// delete the relation
authDao.deleteUserRoleRel(statement, user1.getUserName(), role1.getRoleName());
authDao.deleteUserRoleRel(statement, user1.getUserName(), role2.getRoleName());
assertEquals(0, authDao.getAllUserRoleRel(statement).size());
// delete user and role
authDao.deleteUser(statement, user1.getUserName());
authDao.deleteUser(statement, user2.getUserName());
authDao.deleteRole(statement, role1.getRoleName());
authDao.deleteRole(statement, role2.getRoleName());
}
@Test
public void testUserPermission() {
int permissionId1 = Permission.CREATE;
int permissionId2 = Permission.DELETE;
int permissionId3 = Permission.INSERT;
String nodeName = "nodeName";
authDao.addUser(statement, user1);
// add permission
authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1);
authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId2);
authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId3);
assertEquals(false, authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1));
List<UserPermission> userPermissions = authDao.getUserPermission(statement, user1.getUserName(), nodeName);
assertEquals(3, userPermissions.size());
List<Integer> list = new ArrayList<>();
for (UserPermission userPermission : userPermissions) {
list.add(userPermission.getPermissionId());
}
List<Integer> checkList = new ArrayList<>();
checkList.add(permissionId1);
checkList.add(permissionId2);
checkList.add(permissionId3);
checkList.removeAll(list);
assertEquals(0, checkList.size());
// delete permission
authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId1);
assertEquals(2, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size());
authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId2);
assertEquals(1, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size());
authDao.deleteUserPermission(statement, user1.getUserName(), nodeName, permissionId3);
assertEquals(0, authDao.getUserPermission(statement, user1.getUserName(), nodeName).size());
// delete user
authDao.deleteUser(statement, user1.getUserName());
}
@Test
public void testRolePermission() {
int permissionId1 = Permission.CREATE;
int permissionId2 = Permission.DELETE;
int permissionId3 = Permission.INSERT;
String nodeName = "nodeName";
authDao.addRole(statement, role1);
// add permission
authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1);
authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId2);
authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId3);
assertEquals(false, authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1));
List<RolePermission> rolePermissions = authDao.getRolePermission(statement, role1.getRoleName(), nodeName);
assertEquals(3, rolePermissions.size());
List<Integer> list = new ArrayList<>();
for (RolePermission rolePermission : rolePermissions) {
list.add(rolePermission.getPermissionId());
}
List<Integer> checkList = new ArrayList<>();
checkList.add(permissionId1);
checkList.add(permissionId2);
checkList.add(permissionId3);
checkList.removeAll(list);
assertEquals(0, checkList.size());
// delete permission
authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId1);
assertEquals(2, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size());
authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId2);
assertEquals(1, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size());
authDao.deleteRolePermission(statement, role1.getRoleName(), nodeName, permissionId3);
assertEquals(0, authDao.getRolePermission(statement, role1.getRoleName(), nodeName).size());
// delete user
authDao.deleteRole(statement, role1.getRoleName());
}
@Test
public void testUserAllPermission() {
String nodeName = "nodeName";
String newNodeName = "newNodeName";
int permissionId1 = Permission.CREATE;
int permissionId2 = Permission.DELETE;
int permissionId3 = Permission.INSERT;
// add user
authDao.addUser(statement, user1);
// add role
authDao.addRole(statement, role1);
authDao.addRole(statement, role2);
// only add permission to user
authDao.addUserPermission(statement, user1.getUserName(), nodeName, permissionId1);
assertEquals(1, authDao.getAllUserPermission(statement, user1.getUserName(), nodeName).size());
// add role1 permission
authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId1);
authDao.addRolePermission(statement, role1.getRoleName(), nodeName, permissionId3);
// add permission to different node
authDao.addRolePermission(statement, role1.getRoleName(), newNodeName, permissionId2);
// add role2 permission
authDao.addRolePermission(statement, role2.getRoleName(), nodeName, permissionId1);
// add roles(role1,role2) to user
authDao.addUserRoleRel(statement, user1.getUserName(), role1.getRoleName());
authDao.addUserRoleRel(statement, user1.getUserName(), role2.getRoleName());
// check the all user's permission
assertEquals(2, authDao.getAllUserPermission(statement, user1.getUserName(), nodeName).size());
assertEquals(1, authDao.getAllUserPermission(statement, user1.getUserName(), newNodeName).size());
// delete the user and role
authDao.deleteUser(statement, user1.getUserName());
authDao.deleteRole(statement, role1.getRoleName());
authDao.deleteRole(statement, role2.getRoleName());
}
}

View File

@ -0,0 +1,95 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.sql.Statement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.RoleDao;
import cn.edu.thu.tsfiledb.auth.dao.RolePermissionDao;
import cn.edu.thu.tsfiledb.auth.model.Permission;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.RolePermission;
public class RolePermissionTest {
private DBdao dbDao = null;
private RoleDao roleDao = null;
private RolePermissionDao rolePermissionDao = null;
private Statement statement;
private Role role = new Role("role");
private String nodeName = "nodeName";
private String newNodeName = "newNodeName";
private int permissionId;
private RolePermission rolePermission = null;
@Before
public void setUp() throws Exception {
dbDao = new DBdao();
roleDao = new RoleDao();
rolePermissionDao = new RolePermissionDao();
permissionId = Permission.CREATE;
dbDao.open();
statement = dbDao.getStatement();
// if role not exist, create role
if (roleDao.getRole(statement, role.getRoleName()) == null) {
roleDao.createRole(statement, role);
}
rolePermission = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(), nodeName,
permissionId);
}
@After
public void tearDown() throws Exception {
roleDao.deleteRole(statement, role.getRoleName());
dbDao.close();
}
@Test
public void test() {
// create the role permission
int state = 0;
state = rolePermissionDao.deleteRolePermission(statement, rolePermission);
state = rolePermissionDao.createRolePermission(statement, rolePermission);
RolePermission permission = rolePermissionDao.getRolePermission(statement, rolePermission);
assertEquals(1, state);
assertNotNull(permission);
assertEquals(rolePermission.getRoleId(), permission.getRoleId());
assertEquals(rolePermission.getNodeName(), permission.getNodeName());
assertEquals(rolePermission.getPermissionId(), permission.getPermissionId());
// delete the role permission
state = rolePermissionDao.deleteRolePermission(statement, rolePermission);
assertEquals(1, state);
permission = rolePermissionDao.getRolePermission(statement, rolePermission);
assertNull(permission);
}
@Test
public void testGetRoles() {
RolePermission rolePermission1 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(),
nodeName, Permission.CREATE);
RolePermission rolePermission2 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(),
nodeName, Permission.DELETE);
rolePermissionDao.createRolePermission(statement, rolePermission1);
rolePermissionDao.createRolePermission(statement, rolePermission2);
RolePermission rolePermission3 = new RolePermission(roleDao.getRole(statement, role.getRoleName()).getId(),
newNodeName, Permission.CREATE);
rolePermissionDao.createRolePermission(statement, rolePermission3);
assertEquals(3, rolePermissionDao.getRolePermissions(statement).size());
assertEquals(1, rolePermissionDao.getRolePermissionByRoleAndNodeName(statement,
roleDao.getRole(statement, role.getRoleName()).getId(), newNodeName).size());
}
}

View File

@ -0,0 +1,84 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.*;
import java.sql.Statement;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.RoleDao;
import cn.edu.thu.tsfiledb.auth.model.Role;
public class RoleTest {
private Statement statement = null;
private DBdao dbdao = null;
private RoleDao roleDao = null;
private Role role = null;
private String roleName = "role";
@Before
public void setUp() throws Exception {
dbdao = new DBdao();
dbdao.open();
statement = dbdao.getStatement();
roleDao = new RoleDao();
}
@After
public void tearDown() throws Exception {
dbdao.close();
}
@Test
public void test() {
role = roleDao.getRole(statement, roleName);
if (role != null) {
System.out.println("Delete the original role");
roleDao.deleteRole(statement, roleName);
}
// create role
role = new Role(roleName);
roleDao.createRole(statement, role);
Role getRole = roleDao.getRole(statement, roleName);
assertEquals(roleName, getRole.getRoleName());
// delete role
roleDao.deleteRole(statement, roleName);
role = roleDao.getRole(statement, roleName);
assertEquals(null, role);
}
@Test
public void getRolesTest() {
Role role1 = new Role("role1");
Role role2 = new Role("role2");
ArrayList<Role> arrayList = new ArrayList<>();
arrayList.add(role1);
arrayList.add(role2);
if (roleDao.getRole(statement, role1.getRoleName()) == null) {
roleDao.createRole(statement, role1);
}
if (roleDao.getRole(statement, role2.getRoleName()) == null) {
roleDao.createRole(statement, role2);
}
ArrayList<Role> list = (ArrayList<Role>) roleDao.getRoles(statement);
ArrayList<String> getRoleNames = new ArrayList<>();
for (Role role : list) {
getRoleNames.add(role.getRoleName());
}
ArrayList<String> remove = new ArrayList<>();
remove.add(role1.getRoleName());
remove.add(role2.getRoleName());
getRoleNames.removeAll(remove);
assertEquals(0, getRoleNames.size());
roleDao.deleteRole(statement, role1.getRoleName());
roleDao.deleteRole(statement, role2.getRoleName());
}
}

View File

@ -0,0 +1,90 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.*;
import java.sql.Statement;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.UserDao;
import cn.edu.thu.tsfiledb.auth.dao.UserPermissionDao;
import cn.edu.thu.tsfiledb.auth.model.Permission;
import cn.edu.thu.tsfiledb.auth.model.User;
import cn.edu.thu.tsfiledb.auth.model.UserPermission;
public class UserPemissionTest {
private DBdao DBdao = null;
private UserDao userDao = null;
private UserPermissionDao UserPermissionDao = null;
private Statement statement = null;
private String nodeName = "nodeName";
private String newNodeName = "newNodeName";
private int permission;
private User user = new User("user1", "user1");
@Before
public void setUp() throws Exception {
permission = Permission.CREATE;
DBdao = new DBdao();
DBdao.open();
statement = DBdao.getStatement();
userDao = new UserDao();
UserPermissionDao = new UserPermissionDao();
// if not exitst, create the user
if (userDao.getUser(statement, user.getUserName()) == null) {
userDao.createUser(statement, user);
}
}
@After
public void tearDown() throws Exception {
userDao.deleteUser(statement, user.getUserName());
DBdao.close();
}
@Test
public void test() {
UserPermission userPermission = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(),
nodeName, permission);
// if userpermission exist in the table ,and delete it
UserPermissionDao.deleteUserPermission(statement, userPermission);
// create permission
UserPermissionDao.createUserPermission(statement, userPermission);
UserPermission permission = UserPermissionDao.getUserPermission(statement, userPermission);
assertEquals(userPermission.getUserId(), permission.getUserId());
assertEquals(userPermission.getNodeName(), permission.getNodeName());
assertEquals(userPermission.getPermissionId(), permission.getPermissionId());
// delete permission
int state = 0;
state = UserPermissionDao.deleteUserPermission(statement, userPermission);
assertEquals(1, state);
permission = UserPermissionDao.getUserPermission(statement, userPermission);
assertEquals(null, permission);
}
@Test
public void testGetUserPermissions() {
UserPermission userPermission1 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(),
nodeName, Permission.CREATE);
UserPermission userPermission2 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(),
nodeName, Permission.DELETE);
UserPermissionDao.createUserPermission(statement, userPermission1);
UserPermissionDao.createUserPermission(statement, userPermission2);
assertEquals(2, UserPermissionDao.getUserPermissions(statement).size());
UserPermission userPermission3 = new UserPermission(userDao.getUser(statement, user.getUserName()).getId(),
newNodeName, Permission.CREATE);
UserPermissionDao.createUserPermission(statement, userPermission3);
assertEquals(2, UserPermissionDao.getUserPermissionByUserAndNodeName(statement,
userDao.getUser(statement, user.getUserName()).getId(), nodeName).size());
assertEquals(1, UserPermissionDao.getUserPermissionByUserAndNodeName(statement,
userDao.getUser(statement, user.getUserName()).getId(), newNodeName).size());
}
}

View File

@ -0,0 +1,167 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.*;
import java.sql.Statement;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.RoleDao;
import cn.edu.thu.tsfiledb.auth.dao.UserDao;
import cn.edu.thu.tsfiledb.auth.dao.UserRoleRelDao;
import cn.edu.thu.tsfiledb.auth.model.Role;
import cn.edu.thu.tsfiledb.auth.model.User;
import cn.edu.thu.tsfiledb.auth.model.UserRoleRel;
public class UserRoleRelTest {
private DBdao dbdao = null;
private UserRoleRelDao userRoleRelDao = null;
private UserDao userDao = null;
private RoleDao roleDao = null;
private Statement statement = null;
User user1 = new User("user1", "user2");
User user2 = new User("user2", "user2");
Role role1 = new Role("role1");
Role role2 = new Role("role2");
@Before
public void setUp() throws Exception {
dbdao = new DBdao();
dbdao.open();
statement = dbdao.getStatement();
userDao = new UserDao();
roleDao = new RoleDao();
userRoleRelDao = new UserRoleRelDao();
// create user and role
if (userDao.getUser(statement, user1.getUserName()) == null) {
userDao.createUser(statement, user1);
}
if (userDao.getUser(statement, user2.getUserName()) == null) {
userDao.createUser(statement, user2);
}
if (roleDao.getRole(statement, role1.getRoleName()) == null) {
roleDao.createRole(statement, role1);
}
if (roleDao.getRole(statement, role2.getRoleName()) == null) {
roleDao.createRole(statement, role2);
}
}
@After
public void tearDown() throws Exception {
userDao.deleteUser(statement, user1.getUserName());
userDao.deleteUser(statement, user2.getUserName());
roleDao.deleteRole(statement, role1.getRoleName());
roleDao.deleteRole(statement, role2.getRoleName());
dbdao.close();
}
@Test
public void test() {
// create relation between user and role
String userName = "user1";
String roleName = "role1";
int userId = userDao.getUser(statement, userName).getId();
int roleId = roleDao.getRole(statement, roleName).getId();
UserRoleRel userRoleRel = new UserRoleRel(userId, roleId);
// if not exist, create the relation
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel) == null) {
userRoleRelDao.createUserRoleRel(statement, userRoleRel);
} else {
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel);
userRoleRelDao.createUserRoleRel(statement, userRoleRel);
}
// get the relation
userRoleRel = userRoleRelDao.getUserRoleRel(statement, userRoleRel);
assertEquals(userId, userRoleRel.getUserId());
assertEquals(roleId, userRoleRel.getRoleId());
// delete the relation ana assert
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel);
assertEquals(null, userRoleRelDao.getUserRoleRel(statement, userRoleRel));
}
@Test
public void getRolesByUserTest() {
String user1name = user1.getUserName();
String role1name = role1.getRoleName();
String role2name = role2.getRoleName();
int user1Id = userDao.getUser(statement, user1name).getId();
int role1Id = roleDao.getRole(statement, role1name).getId();
int role2Id = roleDao.getRole(statement, role2name).getId();
UserRoleRel userRoleRel1 = new UserRoleRel(user1Id, role1Id);
UserRoleRel userRoleRel2 = new UserRoleRel(user1Id, role2Id);
// if not exist, create the relations
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel1) == null) {
userRoleRelDao.createUserRoleRel(statement, userRoleRel1);
}
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel2) == null) {
userRoleRelDao.createUserRoleRel(statement, userRoleRel2);
}
// get the relation and assert them
ArrayList<UserRoleRel> arrayList = (ArrayList<UserRoleRel>) userRoleRelDao.getUserRoleRelByUser(statement,
user1Id);
ArrayList<Integer> roleIds = new ArrayList<>();
for (UserRoleRel userRoleRel : arrayList) {
roleIds.add(userRoleRel.getRoleId());
}
ArrayList<Integer> list = new ArrayList<>();
list.add(role1Id);
list.add(role2Id);
roleIds.removeAll(list);
assertEquals(0, roleIds.size());
// delete the relations
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel1);
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel2);
}
@Test
public void getUserByRoleTest() {
String role1name = role1.getRoleName();
String user1name = user1.getUserName();
String user2name = user2.getUserName();
int role1Id = roleDao.getRole(statement, role1name).getId();
int user1Id = userDao.getUser(statement, user1name).getId();
int user2Id = userDao.getUser(statement, user2name).getId();
UserRoleRel userRoleRel1 = new UserRoleRel(user1Id, role1Id);
UserRoleRel userRoleRel2 = new UserRoleRel(user2Id, role1Id);
//if not exist, create the relations
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel1)==null) {
userRoleRelDao.createUserRoleRel(statement, userRoleRel1);
}
if (userRoleRelDao.getUserRoleRel(statement, userRoleRel2)==null) {
userRoleRelDao.createUserRoleRel(statement, userRoleRel2);
}
//get the relation and assert them
ArrayList<UserRoleRel> arrayList = (ArrayList<UserRoleRel>)userRoleRelDao.getUserRoleRelByRole(statement, role1Id);
ArrayList<Integer> userIds = new ArrayList<>();
for (UserRoleRel userRoleRel : arrayList) {
userIds.add(userRoleRel.getUserId());
}
ArrayList<Integer> list = new ArrayList<>();
list.add(user1Id);
list.add(user2Id);
userIds.removeAll(list);
assertEquals(0, userIds.size());
//delete the relations
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel1);
userRoleRelDao.deleteUserRoleRel(statement, userRoleRel2);
}
}

View File

@ -0,0 +1,116 @@
package cn.edu.thu.tsfiledb.auth;
import static org.junit.Assert.*;
import java.sql.Statement;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import cn.edu.thu.tsfiledb.auth.dao.DBdao;
import cn.edu.thu.tsfiledb.auth.dao.UserDao;
import cn.edu.thu.tsfiledb.auth.model.User;
public class UserTest {
private Statement statement = null;
private UserDao userDao = null;
private DBdao dBdao = null;
private String userName = "testuser";
private String passWord = "password";
private User user = new User(userName, passWord);
/**
* @throws Exception
* prepare to connect the derby DB
*/
@Before
public void setUp() throws Exception {
dBdao = new DBdao();
dBdao.open();
statement = dBdao.getStatement();
userDao = new UserDao();
}
@After
public void tearDown() throws Exception {
dBdao.close();
}
/**
* Create user first and delete the user
*/
@Test
public void test() {
User getUser = userDao.getUser(statement, userName);
if (getUser != null) {
int deleteCount = userDao.deleteUser(statement, userName);
if (deleteCount > 0) {
System.out.println("Delete the original record");
}
}
// create user
userDao.createUser(statement, user);
getUser = userDao.getUser(statement, userName);
assertEquals(userName, getUser.getUserName());
assertEquals(passWord, getUser.getPassWord());
// delete user
userDao.deleteUser(statement, userName);
getUser = userDao.getUser(statement, userName);
assertEquals(getUser, null);
}
@Test
public void getUsersTest() {
User user1 = new User("user1", "user1");
User user2 = new User("user2", "user2");
ArrayList<User> arrayList = new ArrayList<>();
arrayList.add(user1);
arrayList.add(user2);
if (userDao.getUser(statement, user1.getUserName()) == null) {
userDao.createUser(statement, user1);
}
if (userDao.getUser(statement, user2.getUserName()) == null) {
userDao.createUser(statement, user2);
}
ArrayList<User> list = (ArrayList<User>) userDao.getUsers(statement);
// add the root user
assertEquals(3, list.size());
// int count = 0;
// // Some problems
// for (User user : list) {
// User testUser = arrayList.get(count);
// count++;
// if (user.getUserName().equals("root")) {
// continue;
// }
// assertEquals(testUser.getUserName(), user.getUserName());
// assertEquals(testUser.getPassWord(), user.getPassWord());
// }
userDao.deleteUser(statement, user1.getUserName());
userDao.deleteUser(statement, user2.getUserName());
}
@Test
public void updateUserTest(){
User user = new User("user", "user");
if ((userDao.getUser(statement, user.getUserName()))==null) {
userDao.createUser(statement, user);
}
user = userDao.getUser(statement, user.getUserName());
assertEquals("user", user.getUserName());
assertEquals("user", user.getPassWord());
// update password
String updatePassword = "password";
userDao.updateUserPassword(statement,
user.getUserName(), updatePassword);
user = userDao.getUser(statement, user.getUserName());
assertEquals("user", user.getUserName());
assertEquals(updatePassword, user.getPassWord());
userDao.deleteUser(statement, user.getUserName());
}
}