Skip to content

Commit 3af0980

Browse files
author
chengyitian
committed
AJ-824: internal support guest user disable execute script;
1 parent d72e14f commit 3af0980

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/com/xxdb/DBConnection.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ public boolean connect(String hostName, int port, String userId, String password
868868
}
869869

870870
try {
871-
bt = (BasicTable) conn_.run("select host,port,(memoryUsed/1024.0/1024.0/1024.0)/maxMemSize as memLoad,ratio(connectionNum,maxConnections) as connLoad,avgLoad from rpc(getControllerAlias(),getClusterPerf) where mode=0",0);
871+
bt = (BasicTable) conn_.run("getClusterPerf", new ArrayList<>(), 0);
872872
break;
873873
} catch (Exception e) {
874874
log.error("ERROR getting other data nodes, exception: " + e.getMessage());
@@ -907,12 +907,18 @@ public boolean connect(String hostName, int port, String userId, String password
907907
// enable loadBalance
908908
//ignore very high load nodes, rand one in low load nodes
909909
List<Node> lowLoadNodes=new ArrayList<>();
910+
BasicIntVector mode = (BasicIntVector) bt.getColumn("mode");
910911
BasicStringVector colHost = (BasicStringVector) bt.getColumn("host");
911912
BasicIntVector colPort = (BasicIntVector) bt.getColumn("port");
912-
BasicDoubleVector memLoad = (BasicDoubleVector) bt.getColumn("memLoad");
913-
BasicDoubleVector connLoad = (BasicDoubleVector) bt.getColumn("connLoad");
913+
BasicLongVector memoryUsed = (BasicLongVector) bt.getColumn("memoryUsed");
914+
BasicDoubleVector maxMemSize = (BasicDoubleVector) bt.getColumn("maxMemSize");
915+
BasicIntVector connectionNum = (BasicIntVector) bt.getColumn("connectionNum");
916+
BasicIntVector maxConnections = (BasicIntVector) bt.getColumn("maxConnections");
914917
BasicDoubleVector avgLoad = (BasicDoubleVector) bt.getColumn("avgLoad");
915918
for (int i = 0; i < colHost.rows(); i++) {
919+
if (mode.getInt(i) != 0)
920+
continue;
921+
916922
Node nodex = new Node(colHost.getString(i), colPort.getInt(i));
917923
Node pexistNode = null;
918924
if (highAvailabilitySites != null) {
@@ -926,15 +932,17 @@ public boolean connect(String hostName, int port, String userId, String password
926932
if (pexistNode == null)
927933
continue;
928934
}
929-
double load=(memLoad.getDouble(i)+connLoad.getDouble(i)+avgLoad.getDouble(i))/3.0;
935+
double memLoad = (memoryUsed.getLong(i) / 1024.0 / 1024.0 /1024.0) / maxMemSize.getDouble(i);
936+
double connLoad = connectionNum.getInt(i) * 1.0 / maxConnections.getInt(i);
937+
double load=(memLoad + connLoad + avgLoad.getDouble(i)) / 3.0;
930938
if (pexistNode != null) {
931939
pexistNode.load = load;
932940
} else {
933941
pexistNode=new Node(colHost.getString(i), colPort.getInt(i), load);
934942
nodes_.add(pexistNode);
935943
}
936944
// low load
937-
if (memLoad.getDouble(i)<0.8 && connLoad.getDouble(i)<0.9 && avgLoad.getDouble(i)<0.8)
945+
if (memLoad < 0.8 && connLoad < 0.9 && avgLoad.getDouble(i) < 0.8)
938946
lowLoadNodes.add(pexistNode);
939947
}
940948

@@ -1514,7 +1522,7 @@ public X509Certificate[] getAcceptedIssuers() {
15141522

15151523
private boolean getServerVersion() throws IOException {
15161524
try {
1517-
Entity ret = conn_.run("version()",0);
1525+
Entity ret = conn_.run("version", new ArrayList<>(), 0);
15181526
if(ret==null){
15191527
throw new IOException("run version failed");
15201528
}

0 commit comments

Comments
 (0)