|
|
@ -15,6 +15,10 @@ import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
public class FilerGrpcClient { |
|
|
|
|
|
|
|
public final int VOLUME_SERVER_ACCESS_DIRECT = 0; |
|
|
|
public final int VOLUME_SERVER_ACCESS_PUBLIC_URL = 1; |
|
|
|
public final int VOLUME_SERVER_ACCESS_FILER_PROXY = 2; |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FilerGrpcClient.class); |
|
|
|
static SslContext sslContext; |
|
|
|
|
|
|
@ -34,6 +38,8 @@ public class FilerGrpcClient { |
|
|
|
private boolean cipher = false; |
|
|
|
private String collection = ""; |
|
|
|
private String replication = ""; |
|
|
|
private int volumeServerAccess = VOLUME_SERVER_ACCESS_DIRECT; |
|
|
|
private String filerAddress; |
|
|
|
|
|
|
|
public FilerGrpcClient(String host, int grpcPort) { |
|
|
|
this(host, grpcPort, sslContext); |
|
|
@ -49,6 +55,8 @@ public class FilerGrpcClient { |
|
|
|
.negotiationType(NegotiationType.TLS) |
|
|
|
.sslContext(sslContext)); |
|
|
|
|
|
|
|
filerAddress = String.format("%s:%d", host, grpcPort-10000); |
|
|
|
|
|
|
|
FilerProto.GetFilerConfigurationResponse filerConfigurationResponse = |
|
|
|
this.getBlockingStub().getFilerConfiguration( |
|
|
|
FilerProto.GetFilerConfigurationRequest.newBuilder().build()); |
|
|
@ -58,7 +66,7 @@ public class FilerGrpcClient { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public FilerGrpcClient(ManagedChannelBuilder<?> channelBuilder) { |
|
|
|
private FilerGrpcClient(ManagedChannelBuilder<?> channelBuilder) { |
|
|
|
channel = channelBuilder.build(); |
|
|
|
blockingStub = SeaweedFilerGrpc.newBlockingStub(channel); |
|
|
|
asyncStub = SeaweedFilerGrpc.newStub(channel); |
|
|
@ -93,4 +101,26 @@ public class FilerGrpcClient { |
|
|
|
return futureStub; |
|
|
|
} |
|
|
|
|
|
|
|
public void setAccessVolumeServerDirectly() { |
|
|
|
this.volumeServerAccess = VOLUME_SERVER_ACCESS_DIRECT; |
|
|
|
} |
|
|
|
public boolean isAccessVolumeServerDirectly() { |
|
|
|
return this.volumeServerAccess == VOLUME_SERVER_ACCESS_DIRECT; |
|
|
|
} |
|
|
|
public void setAccessVolumeServerByPublicUrl() { |
|
|
|
this.volumeServerAccess = VOLUME_SERVER_ACCESS_PUBLIC_URL; |
|
|
|
} |
|
|
|
public boolean isAccessVolumeServerByPublicUrl() { |
|
|
|
return this.volumeServerAccess == VOLUME_SERVER_ACCESS_PUBLIC_URL; |
|
|
|
} |
|
|
|
public void setAccessVolumeServerByFilerProxy() { |
|
|
|
this.volumeServerAccess = VOLUME_SERVER_ACCESS_FILER_PROXY; |
|
|
|
} |
|
|
|
public boolean isAccessVolumeServerByFilerProxy() { |
|
|
|
return this.volumeServerAccess == VOLUME_SERVER_ACCESS_FILER_PROXY; |
|
|
|
} |
|
|
|
public String getFilerAddress() { |
|
|
|
return this.filerAddress; |
|
|
|
} |
|
|
|
|
|
|
|
} |