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
10 changes: 10 additions & 0 deletions sdk-core/src/main/java/io/milvus/v2/client/MilvusClientV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,16 @@ public GetCompactionStateResp getCompactionState(GetCompactionStateReq request)
return rpcUtils.retry(() -> utilityService.getCompactionState(this.getRpcStub(), request));
}

/**
* get plans of a compact task by its ID
*
* @param request get compact plans request
* @return GetCompactPlansResp
*/
public GetCompactionPlansResp getCompactionPlans(GetCompactionPlansReq request) {
return rpcUtils.retry(() -> utilityService.getCompactionPlans(this.getRpcStub(), request));
}

/**
* Get server version
*
Expand Down
72 changes: 72 additions & 0 deletions sdk-core/src/main/java/io/milvus/v2/common/CompactionPlan.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.common;

import java.util.ArrayList;
import java.util.List;

public class CompactionPlan {
private Long target;
private List<Long> sources;

private CompactionPlan(CompactionPlanBuilder builder) {
this.target = builder.target;
this.sources = builder.sources;
}

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

public Long getTarget() {
return this.target;
}

public List<Long> getSources() {
return this.sources;
}

@Override
public String toString() {
return "CompactionPlan{" +
"target=" + target +
", sources=" + sources +
'}';
}

public static class CompactionPlanBuilder {
private Long target = 0L;
private List<Long> sources = new ArrayList<>();

public CompactionPlanBuilder target(long target) {
this.target = target;
return this;
}

public CompactionPlanBuilder sources(List<Long> sources) {
this.sources = sources;
return this;
}

public CompactionPlan build() {
return new CompactionPlan(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public DescribeIndexResp describeIndex(MilvusServiceGrpc.MilvusServiceBlockingSt
DescribeIndexRequest.Builder builder = DescribeIndexRequest.newBuilder()
.setCollectionName(collectionName)
.setFieldName(fieldName == null ? "" : fieldName)
.setIndexName(indexName == null ? "" : indexName);
.setIndexName(indexName == null ? "" : indexName)
.setTimestamp(request.getTimestamp());
if (StringUtils.isNotEmpty(dbName)) {
builder.setDbName(dbName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

import io.milvus.common.resourcegroup.ResourceGroupConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

public class DescribeResourceGroupReq {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

public class DropResourceGroupReq {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

public class ListResourceGroupsReq {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

public class TransferNodeReq {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

public class TransferReplicaReq {
Expand Down Expand Up @@ -75,7 +94,7 @@ public static class TransferReplicaReqBuilder {
private String targetGroupName;
private String collectionName;
private String databaseName;
private Long numberOfReplicas;
private Long numberOfReplicas = 1L;

public TransferReplicaReqBuilder sourceGroupName(String sourceGroupName) {
this.sourceGroupName = sourceGroupName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.resourcegroup.request;

import io.milvus.common.resourcegroup.ResourceGroupConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.milvus.v2.service.utility;

import io.milvus.grpc.*;
import io.milvus.v2.common.CompactionPlan;
import io.milvus.v2.common.CompactionState;
import io.milvus.v2.exception.ErrorCode;
import io.milvus.v2.exception.MilvusClientException;
Expand All @@ -32,6 +33,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

public class UtilityService extends BaseService {
Expand Down Expand Up @@ -81,6 +83,12 @@ public Void waitFlush(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub,
.build());

flushed = flushResponse.getFlushed();
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException t) {
System.out.println("Interrupted: " + t.getMessage());
break;
}
}
}
});
Expand Down Expand Up @@ -132,6 +140,30 @@ public GetCompactionStateResp getCompactionState(MilvusServiceGrpc.MilvusService
.build();
}

public GetCompactionPlansResp getCompactionPlans(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub,
GetCompactionPlansReq request) {
String title = "Get compaction plans";
GetCompactionPlansRequest getRequest = GetCompactionPlansRequest.newBuilder()
.setCompactionID(request.getCompactionID())
.build();
GetCompactionPlansResponse response = blockingStub.getCompactionStateWithPlans(getRequest);
rpcUtils.handleResponse(title, response.getStatus());

List<CompactionPlan> plans = new ArrayList<>();
List<CompactionMergeInfo> infos = response.getMergeInfosList();
infos.forEach(info -> {
plans.add(CompactionPlan.builder()
.target(info.getTarget())
.sources(info.getSourcesList())
.build());
});

return GetCompactionPlansResp.builder()
.state(CompactionState.valueOf(response.getState().name()))
.plans(plans)
.build();
}

public Void createAlias(MilvusServiceGrpc.MilvusServiceBlockingStub blockingStub, CreateAliasReq request) {
String dbName = request.getDatabaseName();
String collectionName = request.getCollectionName();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package io.milvus.v2.service.utility.request;

public class GetCompactionPlansReq {
private Long compactionID;

private GetCompactionPlansReq(GetCompactionPlansReqBuilder builder) {
this.compactionID = builder.compactionID;
}

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

public Long getCompactionID() {
return compactionID;
}

public void setCompactionID(Long compactionID) {
this.compactionID = compactionID;
}

@Override
public String toString() {
return "GetCompactionPlansReq{" +
"compactionID=" + compactionID +
'}';
}

public static class GetCompactionPlansReqBuilder {
private Long compactionID;

public GetCompactionPlansReqBuilder compactionID(Long compactionID) {
this.compactionID = compactionID;
return this;
}

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