public class ServerContext extends Object implements AutoCloseable
DataStore
Note:
It is created in CorfuServer
and then
passed to all the servers including NettyServerRouter
.
Created by mdhawan on 8/5/16.
Modifier and Type | Field and Description |
---|---|
static Duration |
SHUTDOWN_TIMER |
static Duration |
SMALL_INTERVAL
various duration constants.
|
Constructor and Description |
---|
ServerContext(Map<String,Object> serverConfig)
Returns a new ServerContext.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Layout |
copyManagementLayout()
Fetches and creates a copy of the Management Layout from the local datastore.
|
Layout |
getCurrentLayout()
|
CorfuRuntime.CorfuRuntimeParameters |
getDefaultRuntimeParameters()
Get an instance of
CorfuRuntime.CorfuRuntimeParameters representing the default Corfu Runtime's
parameters. |
FailureDetectorMetrics |
getFailureDetectorMetrics()
Get latest change in a cluster state saved in data store.
|
long |
getLogUnitEpochWaterMark()
Fetches the epoch at which the last epochWaterMark operation was received.
|
Layout |
getManagementLayout()
Fetches the management layout from the persistent datastore.
|
Layout |
getNewSingleNodeLayout()
Get a new single node layout used for self-bootstrapping a server started with
the -s flag.
|
UUID |
getNodeId()
Get the node id as an UUID.
|
String |
getNodeIdBase64()
Get the node id as a base64 string.
|
Rank |
getPhase1Rank() |
org.corfudb.infrastructure.Phase2Data |
getPhase2Data() |
long |
getSequencerEpoch()
Fetch the persisted sequencer epoch.
|
<T> T |
getServerConfig(Class<T> type,
String optionName)
Get a field from the server configuration map.
|
long |
getServerEpoch()
The epoch of this router.
|
List<AbstractServer> |
getServers()
Get the list of servers registered in serverRouter
|
String |
getThreadPrefix()
Get the prefix for threads this server creates.
|
boolean |
installSingleNodeLayoutIfAbsent()
Install a single node layout if and only if no layout is currently installed.
|
void |
saveFailureDetectorMetrics(FailureDetectorMetrics detector)
Save detected failure in a history.
|
void |
saveManagementLayout(Layout layout)
Sets the management layout in the persistent datastore.
|
void |
setCurrentLayout(Layout layout)
|
void |
setLayoutInHistory(Layout layout) |
void |
setLogUnitEpochWaterMark(long resetEpoch)
Sets the log unit epoch water mark.
|
void |
setPhase1Rank(Rank rank) |
void |
setPhase2Data(org.corfudb.infrastructure.Phase2Data phase2Data) |
void |
setSequencerEpoch(long sequencerEpoch)
Persists the sequencer epoch.
|
void |
setServerEpoch(long serverEpoch,
IServerRouter r)
Set the serverRouter epoch.
|
public static final Duration SMALL_INTERVAL
public static final Duration SHUTDOWN_TIMER
public CorfuRuntime.CorfuRuntimeParameters getDefaultRuntimeParameters()
CorfuRuntime.CorfuRuntimeParameters
representing the default Corfu Runtime's
parameters.CorfuRuntime.CorfuRuntimeParameters
public UUID getNodeId()
public String getNodeIdBase64()
public <T> T getServerConfig(Class<T> type, String optionName)
T
- The type of the field to return.type
- The type of the field.optionName
- The name of the option to retrieve.public boolean installSingleNodeLayoutIfAbsent()
public Layout getNewSingleNodeLayout()
IllegalArgumentException
- If the cluster id was not auto, base64 or a UUID stringpublic void setCurrentLayout(Layout layout)
public List<AbstractServer> getServers()
public long getServerEpoch()
public void setServerEpoch(long serverEpoch, IServerRouter r)
serverEpoch
- the epoch to setpublic Rank getPhase1Rank()
public void setPhase1Rank(Rank rank)
public org.corfudb.infrastructure.Phase2Data getPhase2Data()
public void setPhase2Data(org.corfudb.infrastructure.Phase2Data phase2Data)
public void setLayoutInHistory(Layout layout)
public void setSequencerEpoch(long sequencerEpoch)
sequencerEpoch
- Epoch to persist.public long getSequencerEpoch()
public void saveManagementLayout(Layout layout)
layout
- Layout to be persistedpublic void saveFailureDetectorMetrics(FailureDetectorMetrics detector)
detector
- failure detector statepublic FailureDetectorMetrics getFailureDetectorMetrics()
public Layout getManagementLayout()
public void setLogUnitEpochWaterMark(long resetEpoch)
resetEpoch
- Epoch at which the reset command was received.public long getLogUnitEpochWaterMark()
public Layout copyManagementLayout()
@Nonnull public String getThreadPrefix()
public void close()
Cleans up and releases all resources (such as thread pools and files) opened
by this ServerContext
.
close
in interface AutoCloseable
Copyright © 2019 CorfuDB. All rights reserved.