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
4 changes: 2 additions & 2 deletions sdk-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand All @@ -177,4 +177,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
110 changes: 71 additions & 39 deletions sdk-core/src/main/java/io/milvus/client/AbstractMilvusGrpcClient.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.milvus.param.partition.*;
import io.milvus.param.resourcegroup.*;
import io.milvus.param.role.*;
import lombok.NonNull;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;
Expand All @@ -56,7 +55,10 @@ public class MilvusMultiServiceClient implements MilvusClient {
* Sets connect param for multi milvus clusters.
* @param multiConnectParam multi server connect param
*/
public MilvusMultiServiceClient(@NonNull MultiConnectParam multiConnectParam) {
public MilvusMultiServiceClient(MultiConnectParam multiConnectParam) {
if (multiConnectParam == null) {
throw new IllegalArgumentException("multiConnectParam must not be null");
}

List<ServerSetting> serverSettings = multiConnectParam.getHosts().stream()
.map(host -> {
Expand Down Expand Up @@ -723,4 +725,3 @@ private <T> R<T> handleResponse(List<R<T>> response) {
return R.failed(R.Status.Unknown, "Response is empty.");
}
}

14 changes: 9 additions & 5 deletions sdk-core/src/main/java/io/milvus/client/MilvusServiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
import io.grpc.stub.MetadataUtils;
import io.milvus.common.utils.ExceptionUtils;
import io.milvus.exception.MilvusException;
import io.milvus.exception.ServerException;
import io.milvus.grpc.*;
Expand All @@ -49,7 +50,6 @@
import io.milvus.v2.utils.ClientUtils;
import io.grpc.ProxiedSocketAddress;
import io.grpc.ProxyDetector;
import lombok.NonNull;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
Expand All @@ -75,7 +75,8 @@ public class MilvusServiceClient extends AbstractMilvusGrpcClient {
private RetryParam retryParam = RetryParam.newBuilder().build();
private String currentDatabaseName;

public MilvusServiceClient(@NonNull ConnectParam connectParam) {
public MilvusServiceClient(ConnectParam connectParam) {
ExceptionUtils.checkNotNull(connectParam, connectParam.getClass().getSimpleName());
this.rpcDeadlineMs = connectParam.getRpcDeadlineMs();

Metadata metadata = new Metadata();
Expand Down Expand Up @@ -417,7 +418,8 @@ private <T> R<T> retry(Callable<R<T>> callable) {
* 3. sdk language type and version
* 4. the client's local time
*/
private R<ConnectResponse> connect(@NonNull ConnectParam connectParam) {
private R<ConnectResponse> connect(ConnectParam connectParam) {
ExceptionUtils.checkNotNull(connectParam, connectParam.getClass().getSimpleName());
ClientInfo info = ClientInfo.newBuilder()
.setSdkType("Java")
.setSdkVersion(getSDKVersion())
Expand Down Expand Up @@ -620,12 +622,14 @@ public R<DescribeIndexResponse> describeIndex(DescribeIndexParam requestParam) {
}

@Override
public R<GetIndexStateResponse> getIndexState(@NonNull GetIndexStateParam requestParam) {
public R<GetIndexStateResponse> getIndexState(GetIndexStateParam requestParam) {
ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName());
return retry(()-> super.getIndexState(requestParam));
}

@Override
public R<GetIndexBuildProgressResponse> getIndexBuildProgress(@NonNull GetIndexBuildProgressParam requestParam) {
public R<GetIndexBuildProgressResponse> getIndexBuildProgress(GetIndexBuildProgressParam requestParam) {
ExceptionUtils.checkNotNull(requestParam, requestParam.getClass().getSimpleName());
return retry(()-> super.getIndexBuildProgress(requestParam));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,32 @@

package io.milvus.common.clientenum;

import lombok.Getter;

public enum ConsistencyLevelEnum {

STRONG("Strong", 0),
SESSION("Session", 1),
BOUNDED("Bounded", 2),
EVENTUALLY("Eventually",3),
EVENTUALLY("Eventually", 3),
;

@Getter
private final String name;

@Getter
private final int code;

ConsistencyLevelEnum(String name, int code){
ConsistencyLevelEnum(String name, int code) {
this.name = name;
this.code = code;
}

private static final ConsistencyLevelEnum[] CONSISTENCY_LEVELS = new ConsistencyLevelEnum[values().length];
// Getter methods to replace @Getter annotations
public String getName() {
return name;
}

public int getCode() {
return code;
}

private static final ConsistencyLevelEnum[] CONSISTENCY_LEVELS = values();

public static ConsistencyLevelEnum getNameByCode(int code) {
if (code >= 0 && code < CONSISTENCY_LEVELS.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,27 @@

package io.milvus.common.clientenum;

import lombok.Getter;

public enum FunctionType {
UNKNOWN("Unknown", 0), // in milvus-proto, the name is "Unknown"
BM25(1),
BM25("BM25", 1), // Added missing name parameter
TEXTEMBEDDING("TextEmbedding", 2), // in milvus-proto, the name is "TextEmbedding"
RERANK(3),
;
RERANK("RERANK", 3); // Added missing name parameter

private final String name;

@Getter
private final int code;

FunctionType(){
this.name = this.name();
this.code = this.ordinal();
FunctionType(String name, int code){
this.name = name;
this.code = code;
}

FunctionType(int code){
this.name = this.name();
this.code = code;
// Getter method to replace @Getter annotation
public int getCode() {
return code;
}

FunctionType(String name, int code){
this.name = name;
this.code = code;
public String getName() {
return name;
}

public static FunctionType fromName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,100 @@

package io.milvus.common.resourcegroup;

import lombok.Data;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;

@Data
@SuperBuilder
public class NodeInfo {
private Long nodeId;
private String address;
private String hostname;

private NodeInfo(Builder builder) {
this.nodeId = builder.nodeId;
this.address = builder.address;
this.hostname = builder.hostname;
}

public Long getNodeId() {
return nodeId;
}

public void setNodeId(Long nodeId) {
this.nodeId = nodeId;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getHostname() {
return hostname;
}

public void setHostname(String hostname) {
this.hostname = hostname;
}

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
NodeInfo nodeInfo = (NodeInfo) obj;
return new EqualsBuilder()
.append(nodeId, nodeInfo.nodeId)
.append(address, nodeInfo.address)
.append(hostname, nodeInfo.hostname)
.isEquals();
}

@Override
public int hashCode() {
int result = nodeId != null ? nodeId.hashCode() : 0;
result = 31 * result + (address != null ? address.hashCode() : 0);
result = 31 * result + (hostname != null ? hostname.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "NodeInfo{" +
"nodeId=" + nodeId +
", address='" + address + '\'' +
", hostname='" + hostname + '\'' +
'}';
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private Long nodeId;
private String address;
private String hostname;

private Builder() {}

public Builder nodeId(Long nodeId) {
this.nodeId = nodeId;
return this;
}

public Builder address(String address) {
this.address = address;
return this;
}

public Builder hostname(String hostname) {
this.hostname = hostname;
return this;
}

public NodeInfo build() {
return new NodeInfo(this);
}
}
}
Loading
Loading