Browse Source

Refine example (#1079)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
groot 9 months ago
parent
commit
3b6fd6cdbe

+ 1 - 2
examples/main/java/io/milvus/v1/BulkWriterExample.java

@@ -78,7 +78,6 @@ import io.milvus.response.QueryResultsWrapper;
 import org.apache.avro.generic.GenericData;
 import org.apache.avro.generic.GenericData;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.util.Asserts;
 import org.apache.http.util.Asserts;
-import org.apache.logging.log4j.util.Strings;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -546,7 +545,7 @@ public class BulkWriterExample {
                     List<KeyValuePair> infosList = bulkInsertState.getInfosList();
                     List<KeyValuePair> infosList = bulkInsertState.getInfosList();
                     Optional<String> failedReasonOptional = infosList.stream().filter(e -> e.getKey().equals("failed_reason"))
                     Optional<String> failedReasonOptional = infosList.stream().filter(e -> e.getKey().equals("failed_reason"))
                             .map(KeyValuePair::getValue).findFirst();
                             .map(KeyValuePair::getValue).findFirst();
-                    String failedReson = failedReasonOptional.orElse(Strings.EMPTY);
+                    String failedReson = failedReasonOptional.orElse("");
 
 
                     System.out.printf("The task %s failed, reason: %s%n", taskId, failedReson);
                     System.out.printf("The task %s failed, reason: %s%n", taskId, failedReson);
                 } else if (bulkInsertState.getState() == ImportState.ImportCompleted) {
                 } else if (bulkInsertState.getState() == ImportState.ImportCompleted) {

+ 5 - 9
examples/main/java/io/milvus/v1/resourcegroup/ResourceGroupManagement.java

@@ -31,8 +31,6 @@ import io.milvus.grpc.ListResourceGroupsResponse;
 import io.milvus.grpc.LoadState;
 import io.milvus.grpc.LoadState;
 import io.milvus.grpc.ShowCollectionsResponse;
 import io.milvus.grpc.ShowCollectionsResponse;
 
 
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
 
 
 public class ResourceGroupManagement {
 public class ResourceGroupManagement {
     public static String RECYCLE_RG = "__recycle_resource_group";
     public static String RECYCLE_RG = "__recycle_resource_group";
@@ -40,8 +38,6 @@ public class ResourceGroupManagement {
     static Integer RECYCLE_RG_REQUEST_NODE_NUM = 0;
     static Integer RECYCLE_RG_REQUEST_NODE_NUM = 0;
     static Integer RECYCLE_RG_LIMIT_NODE_NUM = 100000;
     static Integer RECYCLE_RG_LIMIT_NODE_NUM = 100000;
 
 
-    protected static final Logger logger = LoggerFactory.getLogger(ResourceGroupManagement.class);
-
     private MilvusClient client;
     private MilvusClient client;
 
 
     public ResourceGroupManagement(MilvusClient client) {
     public ResourceGroupManagement(MilvusClient client) {
@@ -99,7 +95,7 @@ public class ResourceGroupManagement {
             }
             }
 
 
             if (resourceGroupNames.size() == 0) {
             if (resourceGroupNames.size() == 0) {
-                logger.info("no loaded collection in database {}", dbName);
+                System.out.println("no loaded collection in database " + dbName);
                 continue;
                 continue;
             } else if (resourceGroupNames.size() == 1) {
             } else if (resourceGroupNames.size() == 1) {
                 // all loaded collection in one resource group.
                 // all loaded collection in one resource group.
@@ -235,8 +231,8 @@ public class ResourceGroupManagement {
         GetLoadStateResponse loadedState = unwrap(loaded);
         GetLoadStateResponse loadedState = unwrap(loaded);
 
 
         if (loadedState.getState() != LoadState.LoadStateLoaded) {
         if (loadedState.getState() != LoadState.LoadStateLoaded) {
-            logger.info("Collection {} @ Database {} is not loaded, state is {}, skip it", collection, dbName,
-                    loaded.getData().getState());
+            System.out.printf("Collection %s @ Database %s is not loaded, state is %s, skip it%n",
+                    collection, dbName, loaded.getData().getState().name());
             return null;
             return null;
         }
         }
 
 
@@ -255,7 +251,7 @@ public class ResourceGroupManagement {
                     replicas.getReplicasCount()));
                     replicas.getReplicasCount()));
         }
         }
         if (replicas.getReplicasCount() == 0) {
         if (replicas.getReplicasCount() == 0) {
-            logger.warn("Collection {} @ Database {} has no replica, skip it", collection, dbName);
+            System.out.printf("Collection %s @ Database %s has no replica, skip it%n", collection, dbName);
             return null;
             return null;
         }
         }
 
 
@@ -274,7 +270,7 @@ public class ResourceGroupManagement {
                 MilvusException e = (MilvusException) response.getException();
                 MilvusException e = (MilvusException) response.getException();
                 throw e;
                 throw e;
             }
             }
-            logger.warn("at unwrap", response.getException());
+            System.out.println("at unwrap " + response.getMessage());
             throw response.getException();
             throw response.getException();
         }
         }
         return response.getData();
         return response.getData();

+ 0 - 7
examples/pom.xml

@@ -65,13 +65,6 @@
             <groupId>io.milvus</groupId>
             <groupId>io.milvus</groupId>
             <artifactId>milvus-sdk-java</artifactId>
             <artifactId>milvus-sdk-java</artifactId>
             <version>2.4.4</version>
             <version>2.4.4</version>
-
-            <exclusions>
-                <exclusion>
-                    <groupId>org.slf4j</groupId>
-                    <artifactId>slf4j-log4j12</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         </dependency>
         <dependency>
         <dependency>
             <groupId>org.tensorflow</groupId>
             <groupId>org.tensorflow</groupId>