pom(grpc):
升级guava版本
This commit is contained in:
		
							parent
							
								
									0527313d26
								
							
						
					
					
						commit
						2ab98b02c1
					
				
							
								
								
									
										21
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								pom.xml
									
									
									
									
									
								
							@ -33,10 +33,10 @@
 | 
				
			|||||||
        <log4j.version>1.2.17</log4j.version>
 | 
					        <log4j.version>1.2.17</log4j.version>
 | 
				
			||||||
        <commons-logging.version>1.3.4</commons-logging.version>
 | 
					        <commons-logging.version>1.3.4</commons-logging.version>
 | 
				
			||||||
        <jakarta-validation.version>3.0.2</jakarta-validation.version>
 | 
					        <jakarta-validation.version>3.0.2</jakarta-validation.version>
 | 
				
			||||||
        <guava.version>32.0.0-jre</guava.version>
 | 
					        <guava.version>33.3.0-jre</guava.version>
 | 
				
			||||||
        <grpc-java.version>1.64.2</grpc-java.version>
 | 
					        <grpc-java.version>1.66.0</grpc-java.version>
 | 
				
			||||||
        <proto-google-common-protos.version>2.43.0</proto-google-common-protos.version>
 | 
					        <proto-google-common-protos.version>2.41.0</proto-google-common-protos.version>
 | 
				
			||||||
        <protobuf-java.version>3.25.4</protobuf-java.version>
 | 
					        <protobuf-java.version>3.25.3</protobuf-java.version>
 | 
				
			||||||
    </properties>
 | 
					    </properties>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <modules>
 | 
					    <modules>
 | 
				
			||||||
@ -203,30 +203,17 @@
 | 
				
			|||||||
                <artifactId>grpc-util</artifactId>
 | 
					                <artifactId>grpc-util</artifactId>
 | 
				
			||||||
                <version>${grpc-java.version}</version>
 | 
					                <version>${grpc-java.version}</version>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
            <dependency>
 | 
					 | 
				
			||||||
                <groupId>io.grpc</groupId>
 | 
					 | 
				
			||||||
                <artifactId>grpc-testing</artifactId>
 | 
					 | 
				
			||||||
                <version>${grpc-java.version}</version>
 | 
					 | 
				
			||||||
                <scope>test</scope>
 | 
					 | 
				
			||||||
            </dependency>
 | 
					 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>com.google.api.grpc</groupId>
 | 
					                <groupId>com.google.api.grpc</groupId>
 | 
				
			||||||
                <artifactId>proto-google-common-protos</artifactId>
 | 
					                <artifactId>proto-google-common-protos</artifactId>
 | 
				
			||||||
                <version>${proto-google-common-protos.version}</version>
 | 
					                <version>${proto-google-common-protos.version}</version>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
 | 
					 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>com.google.protobuf</groupId>
 | 
					                <groupId>com.google.protobuf</groupId>
 | 
				
			||||||
                <artifactId>protobuf-java</artifactId>
 | 
					                <artifactId>protobuf-java</artifactId>
 | 
				
			||||||
                <version>${protobuf-java.version}</version>
 | 
					                <version>${protobuf-java.version}</version>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
            <!-- gRPC dependency end -->
 | 
					            <!-- gRPC dependency end -->
 | 
				
			||||||
 | 
					 | 
				
			||||||
<!--            <dependency>-->
 | 
					 | 
				
			||||||
<!--                <groupId>net.devh</groupId>-->
 | 
					 | 
				
			||||||
<!--                <artifactId>grpc-client-spring-boot-starter</artifactId>-->
 | 
					 | 
				
			||||||
<!--                <version>3.1.0.RELEASE</version>-->
 | 
					 | 
				
			||||||
<!--            </dependency>-->
 | 
					 | 
				
			||||||
        </dependencies>
 | 
					        </dependencies>
 | 
				
			||||||
    </dependencyManagement>
 | 
					    </dependencyManagement>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -68,21 +68,20 @@ public class GrpcClientInvokeHandler<R extends Result<Object>> implements Invoca
 | 
				
			|||||||
        ListenableFuture<GrpcResult> future = GrpcChannel.sendOfUnary(annotation.path(), JsonUtil.toJsonString(args),
 | 
					        ListenableFuture<GrpcResult> future = GrpcChannel.sendOfUnary(annotation.path(), JsonUtil.toJsonString(args),
 | 
				
			||||||
            reqId);
 | 
					            reqId);
 | 
				
			||||||
        SnailJobLog.LOCAL.debug("request complete requestId:[{}] 耗时:[{}ms]", sw.getTotalTimeMillis(), reqId);
 | 
					        SnailJobLog.LOCAL.debug("request complete requestId:[{}] 耗时:[{}ms]", sw.getTotalTimeMillis(), reqId);
 | 
				
			||||||
 | 
					        if (future == null) {
 | 
				
			||||||
 | 
					            return (R) new SnailJobRpcResult(StatusEnum.NO.getStatus(), "future is nulll", null, reqId);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (async) {
 | 
					        if (async) {
 | 
				
			||||||
            if (future == null) {
 | 
					 | 
				
			||||||
                return null;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            Futures.addCallback(future, new FutureCallback<>() {
 | 
					            Futures.addCallback(future, new FutureCallback<>() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                @Override
 | 
					                @Override
 | 
				
			||||||
                public void onSuccess(final GrpcResult result) {
 | 
					                public void onSuccess(final GrpcResult result) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    ByteBuffer byteBuffer = result.getData().getValue().asReadOnlyByteBuffer();
 | 
					                    ByteBuffer byteBuffer = result.getData().getValue().asReadOnlyByteBuffer();
 | 
				
			||||||
                    String str = JsonUtil.parseObject(new ByteBufferBackedInputStream(byteBuffer), String.class);
 | 
					                    Object obj = JsonUtil.parseObject(new ByteBufferBackedInputStream(byteBuffer), Object.class);
 | 
				
			||||||
                    consumer.accept(
 | 
					                    consumer.accept(
 | 
				
			||||||
                        (R) new SnailJobRpcResult(result.getStatus(), result.getMessage(), str, result.getReqId()));
 | 
					                            (R) new SnailJobRpcResult(result.getStatus(), result.getMessage(), obj, result.getReqId()));
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                @Override
 | 
					                @Override
 | 
				
			||||||
@ -96,10 +95,10 @@ public class GrpcClientInvokeHandler<R extends Result<Object>> implements Invoca
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                GrpcResult result = future.get(Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
 | 
					                GrpcResult result = future.get(timeout, unit);
 | 
				
			||||||
                ByteBuffer byteBuffer = result.getData().getValue().asReadOnlyByteBuffer();
 | 
					                ByteBuffer byteBuffer = result.getData().getValue().asReadOnlyByteBuffer();
 | 
				
			||||||
                String str = JsonUtil.parseObject(new ByteBufferBackedInputStream(byteBuffer), String.class);
 | 
					                Object obj = JsonUtil.parseObject(new ByteBufferBackedInputStream(byteBuffer), Object.class);
 | 
				
			||||||
                return (R) new Result(result.getStatus(), result.getMessage(), str);
 | 
					                return (R) new SnailJobRpcResult(result.getStatus(), result.getMessage(), obj, result.getReqId());
 | 
				
			||||||
            } catch (ExecutionException e) {
 | 
					            } catch (ExecutionException e) {
 | 
				
			||||||
                throw e.getCause();
 | 
					                throw e.getCause();
 | 
				
			||||||
            } catch (TimeoutException e) {
 | 
					            } catch (TimeoutException e) {
 | 
				
			||||||
 | 
				
			|||||||
@ -85,12 +85,6 @@
 | 
				
			|||||||
            <groupId>com.google.api.grpc</groupId>
 | 
					            <groupId>com.google.api.grpc</groupId>
 | 
				
			||||||
            <artifactId>proto-google-common-protos</artifactId>
 | 
					            <artifactId>proto-google-common-protos</artifactId>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <!-- 生成的代码使用到了javax的注解 -->
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>javax.annotation</groupId>
 | 
					 | 
				
			||||||
            <artifactId>javax.annotation-api</artifactId>
 | 
					 | 
				
			||||||
            <version>1.3.2</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
    </dependencies>
 | 
					    </dependencies>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <build>
 | 
					    <build>
 | 
				
			||||||
 | 
				
			|||||||
@ -67,7 +67,7 @@ public class GrpcChannel {
 | 
				
			|||||||
        final long reqId) {
 | 
					        final long reqId) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ManagedChannel channel = CHANNEL_MAP.get(Pair.of(hostId, hostIp));
 | 
					        ManagedChannel channel = CHANNEL_MAP.get(Pair.of(hostId, hostIp));
 | 
				
			||||||
        if (Objects.isNull(channel) || !channel.isShutdown() || !channel.isShutdown()) {
 | 
					        if (Objects.isNull(channel) || channel.isShutdown() || channel.isTerminated()) {
 | 
				
			||||||
            removeChannel(channel);
 | 
					            removeChannel(channel);
 | 
				
			||||||
            channel = connect(hostId, hostIp, port);
 | 
					            channel = connect(hostId, hostIp, port);
 | 
				
			||||||
            if (Objects.isNull(channel)) {
 | 
					            if (Objects.isNull(channel)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,7 @@ public class GrpcInterceptor implements ServerInterceptor {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return Contexts.interceptCall(context, serverCall, metadata, serverCallHandler);
 | 
					            return Contexts.interceptCall(context, serverCall, metadata, serverCallHandler);
 | 
				
			||||||
        } finally {
 | 
					        } finally {
 | 
				
			||||||
            log.info("method invoked: {} cast:{}ms", fullMethodName, System.currentTimeMillis() - start);
 | 
					            log.debug("method invoked: {} cast:{}ms", fullMethodName, System.currentTimeMillis() - start);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user