Переглянути джерело

2.3.3.343,fastjson1.2.83,relogin默认周期性可配置

menglu 2 роки тому
батько
коміт
5104ffa939

+ 2 - 2
pom.xml

@@ -4,7 +4,7 @@
 
 	<groupId>com.sagacloud</groupId>
 	<artifactId>zillion-util</artifactId>
-	<version>2.3.3.342</version>
+	<version>2.3.3.343</version>
 
 	<properties>
 		<maven.compiler.source>1.8</maven.compiler.source>
@@ -172,7 +172,7 @@
 		<dependency>
 			<groupId>com.alibaba</groupId>
 			<artifactId>fastjson</artifactId>
-			<version>1.2.70</version>
+			<version>1.2.83</version>
 		</dependency>
 		<dependency>
 			<groupId>org.apache.httpcomponents</groupId>

+ 62 - 62
src/main/java/com/zillion/database/agent/ZillionAgent.java

@@ -287,7 +287,7 @@ public class ZillionAgent implements IZillionAgent {
 			throw new MyException("ZillionAgent: " + "container not initialized");
 		}
 
-		KerberosUtil.reloginFromKeytab(container.DatabaseImpl);
+		KerberosUtil.reloginFromKeytab(container.DatabaseImpl, false, true);
 
 		JSONObject result = new JSONObject();
 		result.put("Result", "failure");
@@ -500,7 +500,7 @@ public class ZillionAgent implements IZillionAgent {
 				String method_name = Thread.currentThread().getStackTrace()[1].getMethodName();
 				String parent_path_meta = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + schema.table_name;
 				String lock_type_meta = "w";
-				// 获取meta锁
+				// 锟斤拷取meta锟斤拷
 				String node_path_meta = ZKLockRW.Create(container.ZK, parent_path_meta, lock_type_meta, this.full_name);
 				try {
 					LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -535,7 +535,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放meta锁
+					// 锟酵凤拷meta锟斤拷
 					ZKLockRW.Finish(container.ZK, node_path_meta);
 					LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 				}
@@ -576,7 +576,7 @@ public class ZillionAgent implements IZillionAgent {
 					String method_name = Thread.currentThread().getStackTrace()[1].getMethodName();
 					String parent_path_meta = zkpath_namespace + ZillionConstant.zk_splitlocks + "/" + schema.table_name;
 					String lock_type_meta = "w";
-					// 获取meta锁
+					// 锟斤拷取meta锟斤拷
 					String node_path_meta = ZKLockRW.Create(container.ZK, parent_path_meta, lock_type_meta, this.full_name);
 					try {
 						LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -653,7 +653,7 @@ public class ZillionAgent implements IZillionAgent {
 					} catch (Exception e) {
 						throw e;
 					} finally {
-						// 释放meta锁
+						// 锟酵凤拷meta锟斤拷
 						ZKLockRW.Finish(container.ZK, node_path_meta);
 						LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 					}
@@ -895,14 +895,14 @@ public class ZillionAgent implements IZillionAgent {
 				throw e;
 			}
 		} else {
-			// 清理OrderBy
+			// 锟斤拷锟斤拷OrderBy
 			if (queryJSON.containsKey("OrderBy")) {
 				JSONArray OrderBy = (JSONArray) queryJSON.get("OrderBy");
 				if (OrderBy == null || OrderBy.size() == 0) {
 					queryJSON.remove("OrderBy");
 				}
 			}
-			// 在指定查询结果集合中二次查询
+			// ��ָ����ѯ��������ж��β�ѯ
 			if ((QueryType.equals("select") || QueryType.equals("combine_select")) && queryJSON.containsKey("QueryTarget")) {
 				JSONObject QueryTarget = (JSONObject) queryJSON.get("QueryTarget");
 				JSONObject QueryResultInner = this.Query(QueryTarget);
@@ -1016,7 +1016,7 @@ public class ZillionAgent implements IZillionAgent {
 				use = schema.useTable(this.container.ZK, this.full_name);
 			}
 			if (use) {
-				// 处理开
+				// 锟斤拷锟斤拷
 				schema.usingAdd();
 				try {
 					JSONArray content = new JSONArray();
@@ -1342,7 +1342,7 @@ public class ZillionAgent implements IZillionAgent {
 						}
 					}
 				}
-				// 处理结束
+				// �������
 				return result;
 			} else {
 				throw new MyException("ZillionAgent: " + namespace + " " + tableName + " useTable fail");
@@ -1374,7 +1374,7 @@ public class ZillionAgent implements IZillionAgent {
 		ZKWrapper zookeeper = this.container.ZK;
 		String parent_path_ns = ZillionConstant.zk_root + ZillionConstant._nslock;
 		String lock_type_ns = "w";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_me = ZKLockRW.Create(zookeeper, parent_path_ns, lock_type_ns, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " nslock:" + " WaitFor " + node_path_me);
@@ -1407,7 +1407,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_me);
 			LogUtil.info(" ********************************** " + method_name + " nslock:" + " finish " + node_path_me);
 		}
@@ -1443,7 +1443,7 @@ public class ZillionAgent implements IZillionAgent {
 		ZKWrapper zookeeper = this.container.ZK;
 		String parent_path_ns = ZillionConstant.zk_root + ZillionConstant._nslock;
 		String lock_type_ns = "w";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_me = ZKLockRW.Create(zookeeper, parent_path_ns, lock_type_ns, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " nslock:" + " WaitFor " + node_path_me);
@@ -1456,7 +1456,7 @@ public class ZillionAgent implements IZillionAgent {
 			String zkpath_namespace = ZillionConstant.zk_root + ZillionConstant._ns + "/" + namespace;
 			String parent_path_meta = zkpath_namespace + ZillionConstant.zk_metalock;
 			String lock_type_meta = "w";
-			// 获取meta锁
+			// 锟斤拷取meta锟斤拷
 			String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 			try {
 				LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -1485,14 +1485,14 @@ public class ZillionAgent implements IZillionAgent {
 			} catch (Exception e) {
 				throw e;
 			} finally {
-				// 释放meta锁
+				// 锟酵凤拷meta锟斤拷
 				ZKLockRW.Finish(zookeeper, node_path_meta);
 				LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 			}
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_me);
 			LogUtil.info(" ********************************** " + method_name + " nslock:" + " finish " + node_path_me);
 		}
@@ -1534,7 +1534,7 @@ public class ZillionAgent implements IZillionAgent {
 				}
 			}
 		}
-		// 检查
+		// ���
 		{
 			ZillionTableSchema schema = new ZillionTableSchema(namespace, tableName);
 			schema.JSON = content;
@@ -1567,7 +1567,7 @@ public class ZillionAgent implements IZillionAgent {
 		String parent_path_table = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + tableName;
 		String lock_type_table = "c";
 		String check_type_table = "c";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -1579,7 +1579,7 @@ public class ZillionAgent implements IZillionAgent {
 
 			boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 			if (success) {
-				// 获取table锁
+				// 锟斤拷取table锟斤拷
 				String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 				try {
 					int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -1593,7 +1593,7 @@ public class ZillionAgent implements IZillionAgent {
 							throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 						}
 
-						// 处理开
+						// 锟斤拷锟斤拷
 						String table_type;
 						if (!content.containsKey("table_type")) {
 							table_type = "index_data";
@@ -1679,7 +1679,7 @@ public class ZillionAgent implements IZillionAgent {
 
 						repo_version_new = ZKRepositoryUtil.ResetRepoVersion(zookeeper, namespace, parent_path_table, lock_type_table);
 						LogUtil.info(" ********************************** " + method_name + " work success ");
-						// 处理结束
+						// �������
 
 						result = true;
 					} else {
@@ -1688,7 +1688,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放table锁
+					// 锟酵凤拷table锟斤拷
 					ZKLockCEDU.Finish(zookeeper, node_path_table);
 					LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 				}
@@ -1698,7 +1698,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_meta);
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 		}
@@ -1830,7 +1830,7 @@ public class ZillionAgent implements IZillionAgent {
 		String lock_type_table = "e";
 		String check_type_table = "d";
 
-		// 无锁修改表结构
+		// �����޸ı�ṹ
 		if (this.container.without_lock) {
 			this.DDL_AlterTable_inner(schema_exist, zookeeper, namespace, tableName, alter_type, alter_content);
 			LogUtil.info(" ********************************** " + method_name + " work success ");
@@ -1844,7 +1844,7 @@ public class ZillionAgent implements IZillionAgent {
 			return result;
 		}
 
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -1856,7 +1856,7 @@ public class ZillionAgent implements IZillionAgent {
 
 			boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 			if (success) {
-				// 获取table锁
+				// 锟斤拷取table锟斤拷
 				String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 				try {
 					int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -1880,7 +1880,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放table锁
+					// 锟酵凤拷table锟斤拷
 					ZKLockCEDU.Finish(zookeeper, node_path_table);
 					LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 				}
@@ -1890,7 +1890,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_meta);
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 		}
@@ -1907,7 +1907,7 @@ public class ZillionAgent implements IZillionAgent {
 		String parent_path_table = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + tableName;
 		String lock_type_table = "e";
 
-		// 处理开
+		// 锟斤拷锟斤拷
 		Stat stat = new Stat();
 		byte[] data_bytes = zookeeper.getData(zkpath_namespace + ZillionConstant.zk_meta_data + "/" + tableName, false, stat);
 		JSONObject content = (JSONObject) FastJsonReaderUtil.Instance().parse(new String(data_bytes, "UTF-8"));
@@ -1932,7 +1932,7 @@ public class ZillionAgent implements IZillionAgent {
 				content.remove("compress");
 			}
 			content.put("compress", compress);
-			// 处理
+			// 锟斤拷锟斤拷
 			for (ZillionTableIndex schema_index : schema_exist.Indexes) {
 				String indexName = schema_index.index_name;
 				if (schema_exist.table_type != null && (schema_exist.table_type.startsWith("split_"))) {
@@ -1965,7 +1965,7 @@ public class ZillionAgent implements IZillionAgent {
 			boolean resident_memory = (Boolean) alter_content.get("resident_memory");
 			content.put("resident_memory", resident_memory);
 
-			// 处理
+			// 锟斤拷锟斤拷
 			for (ZillionTableIndex schema_index : schema_exist.Indexes) {
 				String indexName = schema_index.index_name;
 				String tableNameString = ZillionConstant.prefix_index + (tableName + "." + indexName);
@@ -2033,7 +2033,7 @@ public class ZillionAgent implements IZillionAgent {
 		this.container.DatabaseImpl.meta_query_update_data(namespace, tableName, content);
 
 		int repo_version_new = ZKRepositoryUtil.ResetRepoVersion(zookeeper, namespace, parent_path_table, lock_type_table);
-		// 处理结束
+		// �������
 
 		return repo_version_new;
 	}
@@ -2058,7 +2058,7 @@ public class ZillionAgent implements IZillionAgent {
 		String parent_path_table = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + tableName;
 		String lock_type_table = "d";
 		String check_type_table = "d";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -2070,7 +2070,7 @@ public class ZillionAgent implements IZillionAgent {
 
 			boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 			if (success) {
-				// 获取table锁
+				// 锟斤拷取table锟斤拷
 				String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 				try {
 					int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2084,7 +2084,7 @@ public class ZillionAgent implements IZillionAgent {
 							throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 						}
 
-						// 处理开
+						// 锟斤拷锟斤拷
 						for (ZillionTableIndex schema_index : schema_exist.Indexes) {
 							String indexName = schema_index.index_name;
 							if (schema_exist.table_type != null && (schema_exist.table_type.startsWith("split_"))) {
@@ -2184,7 +2184,7 @@ public class ZillionAgent implements IZillionAgent {
 
 						repo_version_new = ZKRepositoryUtil.ResetRepoVersion(zookeeper, namespace, parent_path_table, lock_type_table);
 						LogUtil.info(" ********************************** " + method_name + " work success ");
-						// 处理结束
+						// �������
 
 						result = true;
 					} else {
@@ -2193,7 +2193,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放table锁
+					// 锟酵凤拷table锟斤拷
 					ZKLockCEDU.Finish(zookeeper, node_path_table);
 					LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 				}
@@ -2203,7 +2203,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_meta);
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 		}
@@ -2254,7 +2254,7 @@ public class ZillionAgent implements IZillionAgent {
 		if (schema_exist == null) {
 			throw new MyException("ZillionAgent: " + "schema not exist: " + namespace + " " + tableName);
 		}
-		// 检查
+		// ���
 		for (int index_index = 0; index_index < index_schemaArray.size(); index_index++) {
 			JSONObject index_schema = (JSONObject) index_schemaArray.get(index_index);
 			String indexName = (String) index_schema.get("Name");
@@ -2281,7 +2281,7 @@ public class ZillionAgent implements IZillionAgent {
 		String parent_path_table = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + tableName;
 		String lock_type_table = "e";
 		String check_type_table = "d";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -2293,7 +2293,7 @@ public class ZillionAgent implements IZillionAgent {
 
 			boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 			if (success) {
-				// 获取table锁
+				// 锟斤拷取table锟斤拷
 				String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 				try {
 					int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2307,7 +2307,7 @@ public class ZillionAgent implements IZillionAgent {
 							throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 						}
 
-						// 处理开
+						// 锟斤拷锟斤拷
 						String table_type = schema_exist.table_type;
 						List<ZillionTableIndex> schema_indexList = new ArrayList<ZillionTableIndex>();
 						for (int index_index = 0; index_index < index_schemaArray.size(); index_index++) {
@@ -2346,7 +2346,7 @@ public class ZillionAgent implements IZillionAgent {
 
 						repo_version_new = ZKRepositoryUtil.ResetRepoVersion(zookeeper, namespace, parent_path_table, lock_type_table);
 						LogUtil.info(" ********************************** " + method_name + " work success ");
-						// 处理结束
+						// �������
 
 						result = true;
 					} else {
@@ -2355,7 +2355,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放table锁
+					// 锟酵凤拷table锟斤拷
 					ZKLockCEDU.Finish(zookeeper, node_path_table);
 					LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 				}
@@ -2365,7 +2365,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_meta);
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 		}
@@ -2408,7 +2408,7 @@ public class ZillionAgent implements IZillionAgent {
 		String parent_path_table = zkpath_namespace + ZillionConstant.zk_tablelocks + "/" + tableName;
 		String lock_type_table = "e";
 		String check_type_table = "d";
-		// 获取meta锁
+		// 锟斤拷取meta锟斤拷
 		String node_path_meta = ZKLockRW.Create(zookeeper, parent_path_meta, lock_type_meta, this.full_name);
 		try {
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " WaitFor " + node_path_meta);
@@ -2420,7 +2420,7 @@ public class ZillionAgent implements IZillionAgent {
 
 			boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 			if (success) {
-				// 获取table锁
+				// 锟斤拷取table锟斤拷
 				String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 				try {
 					int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2434,7 +2434,7 @@ public class ZillionAgent implements IZillionAgent {
 							throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 						}
 
-						// 处理开
+						// 锟斤拷锟斤拷
 						for (int index_index = 0; index_index < indexNameArray.size(); index_index++) {
 							String indexName = (String) indexNameArray.get(index_index);
 							if (schema_exist.table_type != null && (schema_exist.table_type.startsWith("split_"))) {
@@ -2464,7 +2464,7 @@ public class ZillionAgent implements IZillionAgent {
 
 						repo_version_new = ZKRepositoryUtil.ResetRepoVersion(zookeeper, namespace, parent_path_table, lock_type_table);
 						LogUtil.info(" ********************************** " + method_name + " work success ");
-						// 处理结束
+						// �������
 
 						result = true;
 					} else {
@@ -2473,7 +2473,7 @@ public class ZillionAgent implements IZillionAgent {
 				} catch (Exception e) {
 					throw e;
 				} finally {
-					// 释放table锁
+					// 锟酵凤拷table锟斤拷
 					ZKLockCEDU.Finish(zookeeper, node_path_table);
 					LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 				}
@@ -2483,7 +2483,7 @@ public class ZillionAgent implements IZillionAgent {
 		} catch (Exception e) {
 			throw e;
 		} finally {
-			// 释放meta锁
+			// 锟酵凤拷meta锟斤拷
 			ZKLockRW.Finish(zookeeper, node_path_meta);
 			LogUtil.info(" ********************************** " + method_name + " metalock:" + " finish " + node_path_meta);
 		}
@@ -2529,7 +2529,7 @@ public class ZillionAgent implements IZillionAgent {
 		String check_type_table = "d";
 		boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 		if (success) {
-			// 获取table锁
+			// 锟斤拷取table锟斤拷
 			String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 			try {
 				int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2543,7 +2543,7 @@ public class ZillionAgent implements IZillionAgent {
 						throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 					}
 
-					// 处理开
+					// 锟斤拷锟斤拷
 					List<ZillionTableIndex> schema_indexList = new ArrayList<ZillionTableIndex>();
 					for (int index = 0; index < indexNameList.size(); index++) {
 						String indexName = indexNameList.get(index);
@@ -2557,7 +2557,7 @@ public class ZillionAgent implements IZillionAgent {
 						schema_indexList.add(index_exist);
 					}
 					ZillionHashUtil.AddOrRepairIndex(this.container, schema_exist, schema_indexList, false, thread_count, job);
-					// 处理结束
+					// �������
 
 					result = true;
 				} else {
@@ -2566,7 +2566,7 @@ public class ZillionAgent implements IZillionAgent {
 			} catch (Exception e) {
 				throw e;
 			} finally {
-				// 释放table锁
+				// 锟酵凤拷table锟斤拷
 				ZKLockCEDU.Finish(zookeeper, node_path_table);
 				LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 			}
@@ -2611,7 +2611,7 @@ public class ZillionAgent implements IZillionAgent {
 		String check_type_table = "d";
 		boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 		if (success) {
-			// 获取table锁
+			// 锟斤拷取table锟斤拷
 			String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 			try {
 				int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2625,9 +2625,9 @@ public class ZillionAgent implements IZillionAgent {
 						throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 					}
 
-					// 处理开
+					// 锟斤拷锟斤拷
 					ZillionHashUtil.RefreshHash(this.container, schema_exist, thread_count, job);
-					// 处理结束
+					// �������
 
 					result = true;
 				} else {
@@ -2636,7 +2636,7 @@ public class ZillionAgent implements IZillionAgent {
 			} catch (Exception e) {
 				throw e;
 			} finally {
-				// 释放table锁
+				// 锟酵凤拷table锟斤拷
 				ZKLockCEDU.Finish(zookeeper, node_path_table);
 				LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 			}
@@ -2672,7 +2672,7 @@ public class ZillionAgent implements IZillionAgent {
 		String check_type_table = "d";
 		boolean success = ZKLockCEDU.PreCheck(zookeeper, parent_path_table, check_type_table);
 		if (success) {
-			// 获取table锁
+			// 锟斤拷取table锟斤拷
 			String node_path_table = ZKLockCEDU.Create(zookeeper, parent_path_table, lock_type_table, this.full_name);
 			try {
 				int sequence_id = Integer.parseInt(node_path_table.substring(parent_path_table.length() + 3));
@@ -2686,7 +2686,7 @@ public class ZillionAgent implements IZillionAgent {
 						throw new MyException("ZillionAgent: " + "WaitFor fail " + node_path_table);
 					}
 
-					// 处理开
+					// 锟斤拷锟斤拷
 					if (schema_exist.Indexes.size() > 0) {
 						Stat stat = new Stat();
 						byte[] hash_table = this.container.ZK.getData(zkpath_namespace + ZillionConstant.zk_hash_exist + "/" + tableName, false,
@@ -2721,7 +2721,7 @@ public class ZillionAgent implements IZillionAgent {
 					} else {
 						returnJSON.put("Result", "success");
 					}
-					// 处理结束
+					// �������
 
 					result = true;
 				} else {
@@ -2730,7 +2730,7 @@ public class ZillionAgent implements IZillionAgent {
 			} catch (Exception e) {
 				throw e;
 			} finally {
-				// 释放table锁
+				// 锟酵凤拷table锟斤拷
 				ZKLockCEDU.Finish(zookeeper, node_path_table);
 				LogUtil.info(" ********************************** " + method_name + " tablelock:" + " finish " + node_path_table);
 			}

+ 32 - 10
src/main/java/com/zillion/database/util/KerberosUtil.java

@@ -8,7 +8,7 @@ import org.zillion.util.log.LogUtil;
 
 public class KerberosUtil {
 
-	public static void reloginFromKeytab(IDatabase DatabaseImpl) {
+	public static void reloginFromKeytab(IDatabase DatabaseImpl, boolean period, boolean query) {
 		DatabaseImpl_HBase impl = null;
 		if (DatabaseImpl instanceof DatabaseImpl_HBase) {
 			impl = (DatabaseImpl_HBase) DatabaseImpl;
@@ -20,15 +20,37 @@ public class KerberosUtil {
 			String principal = configuration.get("kerberos.principal");
 			String file = configuration.get("keytab.file");
 			if (principal != null && file != null) {
-				// try {
-				// UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
-				// } catch (IOException e) {
-				// LogUtil.error(LogUtil.GetExceptionStackTrace(e));
-				// }
-				try {
-					UserGroupInformation.getLoginUser().reloginFromKeytab();
-				} catch (IOException e) {
-					LogUtil.error(LogUtil.GetExceptionStackTrace(e));
+				boolean relogin = false;
+				if (period) {
+					boolean periodEnable = true;
+					String setValue = configuration.get("zillion.kerberos.relogin.period");
+					if (setValue != null && setValue.equalsIgnoreCase("false")) {
+						periodEnable = false;
+					}
+					if (periodEnable) {
+						relogin = true;
+					}
+				} else if (query) {
+					boolean queryEnable = false;
+					String setValue = configuration.get("zillion.kerberos.relogin.before_query");
+					if (setValue != null && setValue.equalsIgnoreCase("true")) {
+						queryEnable = true;
+					}
+					if (queryEnable) {
+						relogin = true;
+					}
+				}
+				if (relogin) {
+					// try {
+					// UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
+					// } catch (IOException e) {
+					// LogUtil.error(LogUtil.GetExceptionStackTrace(e));
+					// }
+					try {
+						UserGroupInformation.getLoginUser().reloginFromKeytab();
+					} catch (IOException e) {
+						LogUtil.error(LogUtil.GetExceptionStackTrace(e));
+					}
 				}
 			}
 		}

+ 2 - 2
src/main/java/com/zillion/util/table/SchemaRepositoryThread.java

@@ -6,6 +6,7 @@ import org.zillion.util.log.LogUtil;
 
 import com.zillion.database.util.DatabaseImpl_Mix;
 import com.zillion.database.util.DatabaseImpl_MySQL;
+import com.zillion.database.util.KerberosUtil;
 
 public class SchemaRepositoryThread extends Thread {
 	boolean needStop = false;
@@ -56,8 +57,7 @@ public class SchemaRepositoryThread extends Thread {
 					e.printStackTrace();
 				}
 				LogUtil.warn(" ********************************** " + this.helper.full_name + " alive" + "\t" + status);
-
-				// KerberosUtil.reloginFromKeytab(container.DatabaseImpl);
+				KerberosUtil.reloginFromKeytab(container.DatabaseImpl, true, false);
 			}
 
 			if (curr_time.getTime() - last_meta.getTime() >= meta_cycle_count) {

+ 12 - 9
src/test/java/AgentTest_select.java

@@ -42,15 +42,18 @@ public class AgentTest_select {
 		String database_name = "db_test";
 		String table_name = "table_strong_consistency_es";
 
-//		ZillionTableSchema ss = agent.container.repositoryMap.get(database_name).GetTable(table_name);
-//		List<JSONArray> ContentList = new ArrayList<JSONArray>();
-//		boolean not_consistency = StrongConsistencyUtil.not_consistency(ss, agent, database_name, table_name, ContentList);
-//		LogUtil.warn("not_consistency" + "\t" + not_consistency);
-//		for (int i = 0; i < ContentList.size(); i++) {
-//			JSONArray Content = ContentList.get(i);
-//			LogUtil.warn(Content.toJSONString());
-//		}
+		// ZillionTableSchema ss = agent.container.repositoryMap.get(database_name).GetTable(table_name);
+		// List<JSONArray> ContentList = new ArrayList<JSONArray>();
+		// boolean not_consistency = StrongConsistencyUtil.not_consistency(ss, agent, database_name, table_name, ContentList);
+		// LogUtil.warn("not_consistency" + "\t" + not_consistency);
+		// for (int i = 0; i < ContentList.size(); i++) {
+		// JSONArray Content = ContentList.get(i);
+		// LogUtil.warn(Content.toJSONString());
+		// }
 
+//		for (int ii = 0; ii < Integer.MAX_VALUE; ii++) {
+//			Thread.sleep(1000L);
+//		}
 		////////////////////////////////////////////////////////////////
 		JSONArray wrapperObjects = FastJsonReaderUtil.Instance().ReadJSONArray(new File("etc/selects.json"));
 		for (int i = 0; i < wrapperObjects.size(); i++) {
@@ -61,7 +64,7 @@ public class AgentTest_select {
 			try {
 				agent.NDL_AddDatabase(database_name);
 			} catch (Exception e1) {
-				 e1.printStackTrace();
+				// e1.printStackTrace();
 			}
 
 			try {

+ 22 - 14
src/test/java/test/async/AgentTest_async_select.java

@@ -3,6 +3,7 @@ package test.async;
 import java.io.File;
 
 import org.zillion.util.json.Convertor_JSON;
+import org.zillion.util.json.FastJsonUtil;
 import org.zillion.util.json.JSONReaderUtil;
 import org.zillion.util.log.LogUtil;
 
@@ -10,8 +11,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.zillion.database.agent.IZillionAgent;
 import com.zillion.database.agent.ZillionAgentWebImpl;
-import com.zillion.database.async.AsyncJobRepository;
+import com.zillion.database.async.AsyncJob;
 import com.zillion.database.async.AsyncUtil;
+import com.zillion.util.common.ZillionConstant;
 
 public class AgentTest_async_select {
 
@@ -21,7 +23,6 @@ public class AgentTest_async_select {
 		// Configuration configuration = HBaseConfiguration.create();
 		// agent = new ZillionAgent(configuration);
 
-		ZillionAgentWebImpl.async = true;
 		agent = new ZillionAgentWebImpl("http://localhost:8888/metadata-web/");
 		try {
 			agent.Start();
@@ -37,22 +38,29 @@ public class AgentTest_async_select {
 		// } catch (Exception e1) {
 		// // e1.printStackTrace();
 		// }
+		ZillionConstant.export_batch_size = 10000L;
+		boolean sync = true;
+		if (sync) {
+			AsyncJob job = new AsyncJob(null, null);
+			JSONObject result = agent.Query(wrapperObject, false, job);
+			LogUtil.warn(FastJsonUtil.toFormatString(result));
+		} else {
+			String uuid = AsyncUtil.SubmitJob(agent, wrapperObject);
+			while (true) {
+				Thread.sleep(1L);
 
-		String uuid = AsyncUtil.SubmitJob(agent, wrapperObject);
-		while (true) {
-			Thread.sleep(1L);
+				JSONArray itemList = AsyncUtil.TryPopOnePage(uuid);
+				if (itemList.size() > 0) {
+					LogUtil.warn("" + itemList.size() + "\n" + FastJsonUtil.toFormatString(itemList));
+					continue;
+				}
 
-			JSONArray itemList = AsyncUtil.TryPopOnePage(uuid);
-			if (itemList.size() > 0) {
-				LogUtil.warn("" + itemList.size());
-				continue;
+				AsyncUtil.Finish(uuid);
+				break;
 			}
-
-			AsyncUtil.Finish(uuid);
-			break;
+			Thread.sleep(1000L);
+			AsyncUtil.ClearJob(uuid);
 		}
-		Thread.sleep(1000L);
-		AsyncUtil.ClearJob(uuid);
 
 		agent.Stop();
 	}

+ 124 - 61
src/test/java/test/hbase/HBaseTest_originaldata.java

@@ -1,7 +1,11 @@
 package test.hbase;
 
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.InetAddress;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Base64;
 import java.util.Date;
 import java.util.List;
 import java.util.Random;
@@ -15,74 +19,22 @@ import org.apache.hadoop.hbase.client.Connection;
 import org.apache.hadoop.hbase.client.ConnectionFactory;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.zillion.util.common.FileUtil;
 import org.zillion.util.format.FormatStaticUtil;
 import org.zillion.util.log.LogUtil;
 
 import com.zillion.util.common.ByteToObject;
 
-class MyThread extends Thread {
-	Connection connection;
-	TableName tableName;
-	HTable table;
-	String building;
-	String[] meter_array;
-	Long[] funcid_array;
-	String[] receivetime_array;
-
-	public MyThread(Connection connection, TableName tableName, HTable table, String building, String[] meter_array, Long[] funcid_array,
-			String[] receivetime_array) {
-		this.connection = connection;
-		this.tableName = tableName;
-		this.table = table;
-		this.building = building;
-		this.meter_array = meter_array;
-		this.funcid_array = funcid_array;
-		this.receivetime_array = receivetime_array;
-	}
-
-	public void run() {
-		try {
-//			 HTable tableInner = (HTable) connection.getTable(tableName);
-			HTable tableInner = this.table;
-
-			Random rand = new Random();
-			for (int index2 = 0; index2 < meter_array.length; index2++) {
-				String meter = meter_array[index2];
-				for (int index3 = 0; index3 < funcid_array.length; index3++) {
-					Long funcid = funcid_array[index3];
-					List<Put> batch = new ArrayList<Put>();
-					for (int index4 = 0; index4 < receivetime_array.length; index4++) {
-						String receivetime = receivetime_array[index4];
-
-						List<Object> keyValueList = new ArrayList<Object>();
-						keyValueList.add(building);
-						keyValueList.add(meter);
-						keyValueList.add(funcid);
-						keyValueList.add(receivetime);
-						Put row = new Put(HBaseTest_originaldata.BuildKey(keyValueList));
-						row.addColumn(ByteToObject.toBytes("f"), ByteToObject.toBytes("data"), ByteToObject.toBytes(rand.nextDouble()));
-						batch.add(row);
-					}
-					tableInner.put(batch);
-					HBaseTest_originaldata.AddFinishCount(batch.size());
-				}
-			}
-
-//			tableInner.close();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-}
-
 public class HBaseTest_originaldata {
+	static boolean UseKerberos = false;
 	static String database_name = "db_public";
-	static String table_name = "zillion_data_originaldata6";
+	static String table_name = "test_originaldata";
 
-	static int split_count = 3;
+	static int split_count = 10;
 	static int thread_per_split = 10;
 	static int meter_count = 100;
-	static int funcid_count = 10;
+	static int funcid_count = 100;
 	static int receivetime_count = 100;
 
 	static String[] split_array;
@@ -147,12 +99,66 @@ public class HBaseTest_originaldata {
 		return FinishCount;
 	}
 
+	static String get_new_principal(String principal) {
+		String result = null;
+		try {
+			int index_ = principal.indexOf("_HOST");
+			if (index_ != -1) {
+				String prefix = principal.substring(0, index_);
+				String suffix = principal.substring(index_ + "_HOST".length());
+				if (prefix.charAt(prefix.length() - 1) == '/' && suffix.charAt(0) == '@') {
+					result = prefix + InetAddress.getLocalHost().getHostName() + suffix;
+				}
+			}
+		} catch (Exception e) {
+			LogUtil.error(e.getMessage());
+		}
+		return result;
+	}
+
 	public static void main(String[] args) throws Exception {
 		Configuration configuration = HBaseConfiguration.create();
+
+		if (UseKerberos) {
+			String zillion_kerberos_txt = configuration.get("zillion.kerberos.txt");
+			String zillion_kerberos_keytab = configuration.get("zillion.kerberos.keytab");
+			if (zillion_kerberos_txt != null && zillion_kerberos_keytab != null) {
+				byte[] bytes = FileUtil.read_file_bytes(new FileInputStream(zillion_kerberos_txt));
+				String base64String = new String(bytes, "UTF-8");
+				String base64Header = "data:application/octet-stream;base64,";
+				if (base64String.startsWith(base64Header)) {
+					base64String = base64String.substring(base64Header.length());
+				}
+				byte[] keytab_bytes = Base64.getDecoder().decode(base64String);
+				FileUtil.write_file(keytab_bytes, zillion_kerberos_keytab);
+			}
+
+			String principal = configuration.get("kerberos.principal");
+			String file = configuration.get("keytab.file");
+			if (principal != null && file != null) {
+				String jaas_conf_path = configuration.get("zillion.jaas.conf");
+				String krb5_conf_path = configuration.get("zillion.krb5.conf");
+				System.setProperty("java.security.auth.login.config", jaas_conf_path);
+				System.setProperty("java.security.krb5.conf", krb5_conf_path);
+				String new_principal = get_new_principal(principal);
+				if (new_principal != null) {
+					principal = new_principal;
+					configuration.set("kerberos.principal", principal);
+				}
+
+				UserGroupInformation.setConfiguration(configuration);
+				try {
+					UserGroupInformation.loginUserFromKeytab(principal, file);
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+		}
+
 		Connection connection = ConnectionFactory.createConnection(configuration);
 		Admin admin = connection.getAdmin();
 
-		// ´´½¨Êý¾Ý¿â
+		// 创建数�库
 		boolean exist_namespace = false;
 		NamespaceDescriptor[] namespaces = admin.listNamespaceDescriptors();
 		for (NamespaceDescriptor namespace_exist : namespaces) {
@@ -167,11 +173,11 @@ public class HBaseTest_originaldata {
 			admin.createNamespace(namespaceDesc);
 		}
 
-		// ɾ³ý±í
+		// 删除表
 		TableName tableName = TableName.valueOf(database_name, table_name);
 		AdminUtil.deleteTable(admin, tableName);
 
-		// ´´½¨±í
+		// 创建表
 		byte[][] splitKeys = new byte[split_array.length][];
 		for (int i = 0; i < split_array.length; i++) {
 			String split = split_array[i];
@@ -222,6 +228,8 @@ public class HBaseTest_originaldata {
 		LogUtil.info("Second:" + (endTime.getTime() - beginTime.getTime()) / 1000 + "\t" + "TotalCount:" + TotalCount + "\t" + "Speed(num/sec):"
 				+ (int) (1000.0 * TotalCount / (endTime.getTime() - beginTime.getTime())));
 
+		AdminUtil.deleteTable(admin, tableName);
+
 		admin.close();
 		connection.close();
 	}
@@ -276,3 +284,58 @@ public class HBaseTest_originaldata {
 		return result;
 	}
 }
+
+class MyThread extends Thread {
+	Connection connection;
+	TableName tableName;
+	HTable table;
+	String building;
+	String[] meter_array;
+	Long[] funcid_array;
+	String[] receivetime_array;
+
+	public MyThread(Connection connection, TableName tableName, HTable table, String building, String[] meter_array, Long[] funcid_array,
+			String[] receivetime_array) {
+		this.connection = connection;
+		this.tableName = tableName;
+		this.table = table;
+		this.building = building;
+		this.meter_array = meter_array;
+		this.funcid_array = funcid_array;
+		this.receivetime_array = receivetime_array;
+	}
+
+	public void run() {
+		try {
+			// HTable tableInner = (HTable) connection.getTable(tableName);
+			HTable tableInner = this.table;
+
+			Random rand = new Random();
+			for (int index2 = 0; index2 < meter_array.length; index2++) {
+				String meter = meter_array[index2];
+				for (int index3 = 0; index3 < funcid_array.length; index3++) {
+					Long funcid = funcid_array[index3];
+					List<Put> batch = new ArrayList<Put>();
+					for (int index4 = 0; index4 < receivetime_array.length; index4++) {
+						String receivetime = receivetime_array[index4];
+
+						List<Object> keyValueList = new ArrayList<Object>();
+						keyValueList.add(building);
+						keyValueList.add(meter);
+						keyValueList.add(funcid);
+						keyValueList.add(receivetime);
+						Put row = new Put(HBaseTest_originaldata.BuildKey(keyValueList));
+						row.addColumn(ByteToObject.toBytes("f"), ByteToObject.toBytes("data"), ByteToObject.toBytes(rand.nextDouble()));
+						batch.add(row);
+					}
+					tableInner.put(batch);
+					HBaseTest_originaldata.AddFinishCount(batch.size());
+				}
+			}
+
+			// tableInner.close();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

+ 8 - 0
src/test/resources/hbase-site.xml

@@ -31,6 +31,14 @@
 	<name>zillion.kerberos.keytab</name>
 	<value>D:/Test/kerberos/kerberos.keytab</value>
 </property>
+<property>
+	<name>zillion.kerberos.relogin.period</name>
+	<value>true</value>
+</property>
+<property>
+	<name>zillion.kerberos.relogin.before_query</name>
+	<value>false</value>
+</property>
 	-->
 	
 	<!--