public class RpcServerService extends Object implements SimpleService
RpcServerService.Factory
.
Manages the behavior of the master's rpc service. It deploys a rpc server only after being
promoted. It stops said rpc web server after being demoted or stopped. When a rpc server is not
deployed, a rejecting server is deployed instead (after the service has been started).Modifier and Type | Class and Description |
---|---|
static class |
RpcServerService.Factory
Factory to create an
RpcServerService . |
Modifier and Type | Field and Description |
---|---|
protected static org.slf4j.Logger |
LOG |
protected InetSocketAddress |
mBindAddress |
protected GrpcServer |
mGrpcServer
The grpc server and its executor service (
mRpcExecutor ) need to be managed
independently (i.e. |
protected MasterProcess |
mMasterProcess |
protected MasterRegistry |
mMasterRegistry |
protected RejectingServer |
mRejectingGrpcServer |
protected AlluxioExecutorService |
mRpcExecutor |
Modifier | Constructor and Description |
---|---|
protected |
RpcServerService(InetSocketAddress bindAddress,
MasterProcess masterProcess,
MasterRegistry masterRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
demote()
Demotes the service back to
NodeState.STANDBY state. |
boolean |
isServing() |
void |
promote()
Promotes the service to
NodeState.PRIMARY state. |
void |
start()
Starts the service.
|
protected void |
startGrpcServer(java.util.function.Function<Master,Map<ServiceType,GrpcService>> serviceProvider) |
protected void |
startRejectingServer() |
void |
stop()
Stops the service altogether and cleans up any state left.
|
protected void |
stopGrpcServer() |
protected void |
stopRejectingServer() |
protected void |
stopRpcExecutor() |
static void |
waitFor(boolean freeOrBound,
InetSocketAddress address)
Creates a buffer between rejecting server and regular serving server of at most 1 second.
|
protected void |
waitForBound() |
protected void |
waitForFree() |
protected static final org.slf4j.Logger LOG
protected final InetSocketAddress mBindAddress
protected final MasterProcess mMasterProcess
protected final MasterRegistry mMasterRegistry
@Nullable protected GrpcServer mGrpcServer
mRpcExecutor
) need to be managed
independently (i.e. stopping the grpc server will not automatically stop the rpc executor)@Nullable protected AlluxioExecutorService mRpcExecutor
@Nullable protected RejectingServer mRejectingGrpcServer
protected RpcServerService(InetSocketAddress bindAddress, MasterProcess masterProcess, MasterRegistry masterRegistry)
public boolean isServing()
public void start()
SimpleService
NodeState.STANDBY
state.
Leaves the service in the same state as SimpleService.demote()
.
Can only be called once.start
in interface SimpleService
public void promote()
SimpleService
NodeState.PRIMARY
state.
Can only be called on a started service (i.e. SimpleService.start()
must precede this method).
Can only be called in NodeState.STANDBY
state.
Can be called multiple times (e.g. a service is promoted, then demoted, then promoted again).promote
in interface SimpleService
protected void startGrpcServer(java.util.function.Function<Master,Map<ServiceType,GrpcService>> serviceProvider)
public void demote()
SimpleService
NodeState.STANDBY
state.
Can only be called on a started service (i.e. SimpleService.start()
must precede this method).
Can only be called in NodeState.PRIMARY
state (i.e. SimpleService.promote()
must precede this method).
Can be called multiple times (e.g. a service is promoted, then demoted, then promoted again,
and demoted again).demote
in interface SimpleService
public void stop()
SimpleService
SimpleService.start()
has not been called on this service this method should be a noop.
Can only be called once.stop
in interface SimpleService
protected void stopGrpcServer()
protected void stopRpcExecutor()
protected void startRejectingServer()
protected void stopRejectingServer()
protected void waitForFree()
protected void waitForBound()
public static void waitFor(boolean freeOrBound, InetSocketAddress address)
freeOrBound
- determines if it prematurely returns when the port if free (false) or
bound (true)address
- the address to testCopyright © 2023. All Rights Reserved.