public class Layout extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Layout.LayoutSegment |
static class |
Layout.LayoutStripe |
static class |
Layout.ReplicationMode |
Modifier and Type | Field and Description |
---|---|
static long |
INVALID_EPOCH
Invalid epoch value.
|
static Comparator<Layout> |
LAYOUT_COMPARATOR
Sorting layouts according to epochs in descending order
|
Constructor and Description |
---|
Layout(Layout layout)
Layout copy constructor.
|
Layout(List<String> layoutServers,
List<String> sequencers,
List<Layout.LayoutSegment> segments,
List<String> unresponsiveServers,
long epoch,
UUID clusterId)
Defensive constructor since we can create a Layout from a JSON file.
|
Layout(List<String> layoutServers,
List<String> sequencers,
List<Layout.LayoutSegment> segments,
long epoch,
UUID clusterId) |
Modifier and Type | Method and Description |
---|---|
String |
asJSONString()
Get the layout as a JSON string.
|
static Layout |
fromJSONString(String json)
Get a layout from a JSON string.
|
com.google.common.collect.ImmutableList<String> |
getActiveLayoutServers() |
Set<String> |
getAllActiveServers()
This function returns a set of all active servers in the layout.
|
Set<String> |
getAllServers()
This function returns a set of all servers in the layout.
|
Layout.LayoutSegment |
getFirstSegment()
Get the first segment.
|
long |
getGlobalAddress(Layout.LayoutStripe stripe,
long localAddress)
Return global address for a given stripe.
|
String |
getLastAddedNodeInLastSegment()
Get the last node in the last segment.
|
Layout.LayoutSegment |
getLatestSegment()
Return latest segment.
|
long |
getLocalAddress(long globalAddress)
Given the log's global address, return equivalent local address for a striped log segment.
|
List<Layout.LayoutSegment> |
getPrefixSegments(long globalAddress)
Return a list of segments which contain global
addresses less than or equal to the given address
(known as the prefix).
|
String |
getPrimarySequencer()
Returns the primary sequencer.
|
Layout.ReplicationMode |
getReplicationMode(long address)
Get the replication mode of a segment at a particular address.
|
Layout.LayoutSegment |
getSegment(long globalAddress)
Return layout segment.
|
int |
getSegmentLength(long address)
Get the length of a segment at a particular address.
|
List<Layout.LayoutSegment> |
getSegmentsForEndpoint(String endpoint)
Return all the segments that an endpoint participates in.
|
Layout.LayoutStripe |
getStripe(long globalAddress)
Return layout segment stripe.
|
void |
nextEpoch() |
public static final Comparator<Layout> LAYOUT_COMPARATOR
public static final long INVALID_EPOCH
public Layout(@NonNull List<String> layoutServers, @NonNull List<String> sequencers, @NonNull List<Layout.LayoutSegment> segments, @NonNull List<String> unresponsiveServers, long epoch, @Nullable UUID clusterId)
public Layout(List<String> layoutServers, List<String> sequencers, List<Layout.LayoutSegment> segments, long epoch, UUID clusterId)
public List<Layout.LayoutSegment> getSegmentsForEndpoint(@Nonnull String endpoint)
endpoint
- the endpoint to return all the segments forpublic Set<String> getAllActiveServers()
public Set<String> getAllServers()
public String getPrimarySequencer()
public long getLocalAddress(long globalAddress)
globalAddress
- The global addresspublic long getGlobalAddress(Layout.LayoutStripe stripe, long localAddress)
stripe
- The layout stripe.localAddress
- The local address.@Nonnull public List<Layout.LayoutSegment> getPrefixSegments(long globalAddress)
globalAddress
- The global address prefix
to use.public Layout.LayoutStripe getStripe(long globalAddress)
globalAddress
- The global address.public Layout.LayoutSegment getSegment(long globalAddress)
globalAddress
- The global address.public Layout.LayoutSegment getFirstSegment()
public Layout.LayoutSegment getLatestSegment()
public String getLastAddedNodeInLastSegment()
public int getSegmentLength(long address)
address
- The address to check.public Layout.ReplicationMode getReplicationMode(long address)
address
- The address to check.public String asJSONString()
public void nextEpoch()
public com.google.common.collect.ImmutableList<String> getActiveLayoutServers()
Copyright © 2019 CorfuDB. All rights reserved.