public class LayoutBuilder extends Object
Created by zlokhandwala on 10/12/16.
Constructor and Description |
---|
LayoutBuilder(Layout layout)
Copies the attributes of the layout to make modifications.
|
Modifier and Type | Method and Description |
---|---|
LayoutBuilder |
addLayoutServer(String endpoint)
Adds a new layout server.
|
LayoutBuilder |
addLogunitServer(int stripeIndex,
long globalLogTail,
String newLogunitEndpoint)
Adds a new logunit server.
|
LayoutBuilder |
addLogunitServerToSegment(String endpoint,
int segmentIndex,
int stripeIndex)
Add a log unit server to a specific stripe in a specific segment.
|
LayoutBuilder |
addSequencerServer(String endpoint)
Adds a new sequencer server.
|
LayoutBuilder |
addUnresponsiveServers(Set<String> endpoints)
Adds unresponsive servers in the list.
|
LayoutBuilder |
assignResponsiveSequencerAsPrimary(Set<String> endpoints)
Moves a responsive server to the top of the sequencer server list.
|
Layout |
build()
Builds and returns the layout with the modified attributes.
|
LayoutBuilder |
clearUnResponsiveServers()
Clears the existing unresponsive servers.
|
LayoutBuilder |
mergePreviousSegment(int segmentIndex)
Merges the specified segment and the segment before this.
|
void |
removeFromStripe(String endpoint,
Layout.LayoutStripe layoutStripe,
int minReplicationFactor)
Remove an endpoint from a segment.
|
LayoutBuilder |
removeLayoutServer(String endpoint)
Removes the Layout Server passed.
|
LayoutBuilder |
removeLayoutServers(Set<String> endpoints)
Removes all the Layout Server endpoints present in the set passed.
|
LayoutBuilder |
removeLogunitServer(String endpoint)
Removes the Log unit endpoint from the layout.
|
LayoutBuilder |
removeLogunitServers(Set<String> endpoints)
Removes the Log unit endpoints from the layout.
|
LayoutBuilder |
removeSequencerServer(String endpoint)
Removes the Sequencer Server passed.
|
LayoutBuilder |
removeSequencerServers(Set<String> endpoints)
Removes all the Sequencer Server endpoints present in the set passed.
|
LayoutBuilder |
removeUnresponsiveServer(String endpoint)
Removes a server from layout's list of unresponsive servers.
|
LayoutBuilder |
removeUnresponsiveServers(Set<String> endpoints)
Removes unresponsive servers.
|
LayoutBuilder |
setEpoch(long epoch)
Set layout's epoch
|
public LayoutBuilder(@NonNull Layout layout)
layout
- a non null base layout to be modified.public LayoutBuilder setEpoch(long epoch)
epoch
- epoch to setpublic LayoutBuilder clearUnResponsiveServers()
public LayoutBuilder addUnresponsiveServers(@NonNull Set<String> endpoints)
endpoints
- a non null set of Strings representing endpoints to
be added to the list of layout's unresponsive servers.public LayoutBuilder removeUnresponsiveServers(@NonNull Set<String> endpoints)
endpoints
- a non null set of endpoints to be removed from the layout's
list of unresponsive servers.public LayoutBuilder removeUnresponsiveServer(@NonNull String endpoint)
endpoint
- the endpoint of the unresponsive server to be removedpublic LayoutBuilder removeLayoutServer(@NonNull String endpoint)
endpoint
- a non null string representing the Layout Server endpoint
that needs to be removedLayoutModificationException
- is thrown if the provided endpoint is the last remaining
Layout Serverpublic LayoutBuilder removeLayoutServers(@NonNull Set<String> endpoints)
endpoints
- a non null set of Strings representing Layout server endpoints
to be removed from the layout.LayoutModificationException
- is thrown if removing the provided set of
endpoints result in removing all the remaining Layout Servers in
the layout.public LayoutBuilder addLayoutServer(@NonNull String endpoint)
endpoint
- a non null String representing the Layout Server endpoint
to be added.public LayoutBuilder addSequencerServer(@NonNull String endpoint)
endpoint
- a non null String representing the Sequencer Server endpoint
to be added.public LayoutBuilder addLogunitServer(int stripeIndex, long globalLogTail, @NonNull String newLogunitEndpoint)
stripeIndex
- stripe index where new endpoint should be added.globalLogTail
- Global log tail to split segment.newLogunitEndpoint
- a non null String representing Logunit endpoint to be added.public LayoutBuilder addLogunitServerToSegment(@NonNull String endpoint, int segmentIndex, int stripeIndex)
endpoint
- a non null endpoint to add to the log unit list.segmentIndex
- Segment to which the log unit is to be added.stripeIndex
- Stripe to which the log unit is to be added.public LayoutBuilder mergePreviousSegment(int segmentIndex)
segmentIndex
- Segment to merge.public LayoutBuilder assignResponsiveSequencerAsPrimary(@NonNull Set<String> endpoints)
endpoints
- a non null set of Strings representing failed endpointsLayoutModificationException
- is thrown if none of the sequencers in layout
can be moved to the top of sequencer server list due to being unresponsive
or a failed endpoint.public LayoutBuilder removeSequencerServer(@NonNull String endpoint)
endpoint
- a non null string representing the sequencer server endpoint
which needs to be removedLayoutModificationException
- is thrown if the provided endpoint is the last remaining
Sequencer Serverpublic LayoutBuilder removeSequencerServers(@NonNull Set<String> endpoints)
endpoints
- a non null set of Strings representing sequencer server endpoints
to be removed from the layout.LayoutModificationException
- is thrown if removing the provided set of
endpoints result in removing all the remaining Sequencer Servers in
the layout.public void removeFromStripe(@NonNull String endpoint, @NonNull Layout.LayoutStripe layoutStripe, int minReplicationFactor)
endpoint
- A non null String representing the endpoint to
be removedlayoutStripe
- A non null stripe to remove the endpoint fromminReplicationFactor
- The least number of nodes needed to
maintain redundancypublic LayoutBuilder removeLogunitServer(@NonNull String endpoint)
endpoint
- a non null Log unit server to be removedpublic LayoutBuilder removeLogunitServers(@NonNull Set<String> endpoints)
endpoints
- a non null set of Strings representing Log unit servers
to be removedpublic Layout build()
Copyright © 2019 CorfuDB. All rights reserved.