Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package com.vesoft.nebula.driver.graph.decode;

import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.bytesToInt16;
import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.bytesToUInt16;
import static com.vesoft.nebula.driver.graph.decode.DecodeUtils.charset;
import static com.vesoft.nebula.driver.graph.decode.struct.SizeConstant.ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE;

Expand All @@ -31,7 +31,7 @@ public ByteString read(int len) {
}

public String readSizedString(ByteOrder byteOrder) {
int length = bytesToInt16(read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
int length = bytesToUInt16(read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
int startIndex = index;
index += length;
ByteString strBytes = data.substring(startIndex, startIndex + length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
case COLUMN_TYPE_LIST:
ColumnType eleType = ColumnType.getColumnType(
bytesToInt8(reader.read(VALUE_TYPE_SIZE)));
int listSize = bytesToInt16(
int listSize = bytesToUInt16(
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
int nullBitSize = (listSize % 8 == 0) ? (listSize / 8) : (listSize / 8 + 1);
ByteString nullBitBytes = reader.read(nullBitSize);
Expand All @@ -986,7 +986,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
}
return values;
case COLUMN_TYPE_RECORD:
int recordSize = bytesToInt16(
int recordSize = bytesToUInt16(
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
Map<String, ValueWrapper> map = new HashMap<>();
for (int i = 0; i < recordSize; i++) {
Expand All @@ -1002,7 +1002,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
long nodeId = bytesToInt64(reader.read(NODE_ID_SIZE), byteOrder);
int nodeTypeId = getNodeTypeIdFromNodeId(nodeId);
int nodeGraphId = bytesToInt32(reader.read(GRAPH_ID_SIZE), byteOrder);
int nodePropNum = bytesToInt16(
int nodePropNum = bytesToUInt16(
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
Map<String, ValueWrapper> nodeProperties = new HashMap<>();
for (int i = 0; i < nodePropNum; i++) {
Expand All @@ -1020,7 +1020,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
long rank = bytesToInt64(reader.read(RANK_SIZE), byteOrder);
int edgeGraphId = bytesToInt32(reader.read(GRAPH_ID_SIZE), byteOrder);
int edgeTypeId = bytesToInt32(reader.read(EDGE_TYPE_ID_SIZE), byteOrder);
int edgePropNum = bytesToInt16(
int edgePropNum = bytesToUInt16(
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
Map<String, ValueWrapper> edgeProperties = new HashMap<>();
for (int i = 0; i < edgePropNum; i++) {
Expand All @@ -1038,7 +1038,7 @@ private Object decodeCompositeValue(BytesReader reader, ColumnType type) {
edgeProperties,
graphSchemas);
case COLUMN_TYPE_PATH:
int elementNum = bytesToInt16(
int elementNum = bytesToUInt16(
reader.read(ELEMENT_NUMBER_SIZE_FOR_ANY_VALUE), byteOrder);
List<ValueWrapper> eleValues = new ArrayList<>();
for (int i = 0; i < elementNum; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Constants {
static final long DEFAULT_HEALTH_CHECK_TIME_MS = 5 * 60 * 1000;
static final boolean DEFAULT_TEST_ON_BORROW = true;
static final boolean DEFAULT_BLOCK_WHEN_EXHAUSTED = false;
static final long DEFAULT_MAX_WAIT_MS = Long.MAX_VALUE;
static final long DEFAULT_MAX_WAIT_MS = Long.MAX_VALUE / 1000;
static final long DEFAULT_IDLE_EVICT_SCHEDULE_MS = -1;
static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MS = 30 * 60 * 1000;
static final boolean DEFAULT_STRICT_SERVER_HEALTHY = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static com.vesoft.nebula.driver.graph.net.Constants.DEFAULT_ENABLE_TLS;
import static com.vesoft.nebula.driver.graph.net.Constants.DEFAULT_MAX_LIFE_TIME_MS;
import static com.vesoft.nebula.driver.graph.net.Constants.DEFAULT_MAX_PING_TIMEOUT_MS;
import static com.vesoft.nebula.driver.graph.net.Constants.DEFAULT_MAX_WAIT_MS;

import com.vesoft.nebula.driver.graph.data.HostAddress;
import com.vesoft.nebula.driver.graph.exception.AuthFailedException;
Expand Down Expand Up @@ -75,8 +76,8 @@ private NebulaPool(Builder builder) throws IOErrorException, AuthFailedException
}

ClientPoolFactory factory = new ClientPoolFactory(
loadBalancer,
builder);
loadBalancer,
builder);
pool = new GenericObjectPool<>(factory, objConfig);
hasInit.compareAndSet(false, true);
}
Expand All @@ -96,7 +97,7 @@ public NebulaClient getClient() throws Exception {
*/
public void returnClient(NebulaClient client) {
if (client.isClosed()
|| (System.currentTimeMillis() - client.getCreateTime()) >= maxLifeMills) {
|| (System.currentTimeMillis() - client.getCreateTime()) >= maxLifeMills) {
try {
pool.invalidateObject(client);
} catch (Exception e) {
Expand Down Expand Up @@ -168,7 +169,7 @@ public static class Builder {

// the max wait time if blockWhenExhausted is true. if value is less than 0, always wait.
// unit: millisecond
protected long maxWaitMills = Constants.DEFAULT_MAX_WAIT_MS;
protected long maxWaitMills = DEFAULT_MAX_WAIT_MS;

// the schedule time for test the idle session and evict it. if value is less than 0,
// never evict the idle sessions.
Expand Down Expand Up @@ -272,7 +273,7 @@ public Builder withMinClientSize(int minClientSize) {
*/
public Builder withConnectTimeoutMills(long connectTimeoutMills) {
if (connectTimeoutMills <= 0
|| connectTimeoutMills > Constants.DEFAULT_MAX_TIMEOUT_MS) {
|| connectTimeoutMills > Constants.DEFAULT_MAX_TIMEOUT_MS) {
this.connectTimeoutMills = Constants.DEFAULT_MAX_TIMEOUT_MS;
} else {
this.connectTimeoutMills = connectTimeoutMills;
Expand All @@ -289,7 +290,7 @@ public Builder withConnectTimeoutMills(long connectTimeoutMills) {
*/
public Builder withRequestTimeoutMills(long requestTimeoutMills) {
if (requestTimeoutMills <= 0
|| requestTimeoutMills > Constants.DEFAULT_MAX_TIMEOUT_MS) {
|| requestTimeoutMills > Constants.DEFAULT_MAX_TIMEOUT_MS) {
this.requestTimeoutMills = Constants.DEFAULT_MAX_TIMEOUT_MS;
} else {
this.requestTimeoutMills = requestTimeoutMills;
Expand All @@ -306,7 +307,7 @@ public Builder withRequestTimeoutMills(long requestTimeoutMills) {
*/
public Builder withServerPingTimeoutMills(long serverPingTimeoutMills) {
if (serverPingTimeoutMills < 0
|| serverPingTimeoutMills > DEFAULT_MAX_PING_TIMEOUT_MS) {
|| serverPingTimeoutMills > DEFAULT_MAX_PING_TIMEOUT_MS) {
this.serverPingTimeoutMills = DEFAULT_MAX_PING_TIMEOUT_MS;
} else {
this.serverPingTimeoutMills = serverPingTimeoutMills;
Expand Down Expand Up @@ -357,7 +358,11 @@ public Builder withTestOnBorrow(boolean testOnBorrow) {
* @return NebulaPool.Builder
*/
public Builder withMaxWaitMills(long maxWaitMills) {
this.maxWaitMills = maxWaitMills <= 0 ? Long.MAX_VALUE : maxWaitMills;
if (maxWaitMills <= 0 || maxWaitMills > DEFAULT_MAX_WAIT_MS) {
this.maxWaitMills = DEFAULT_MAX_WAIT_MS;
} else {
this.maxWaitMills = maxWaitMills;
}
return this;
}

Expand Down