remove PROTOTYPE from DiscoveryNode
This commit is contained in:
parent
030453d320
commit
cd05cf91f0
|
@ -73,7 +73,7 @@ public class TaskInfo implements Writeable<TaskInfo>, ToXContent {
|
|||
}
|
||||
|
||||
public TaskInfo(StreamInput in) throws IOException {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
taskId = new TaskId(node.getId(), in.readLong());
|
||||
type = in.readString();
|
||||
action = in.readString();
|
||||
|
|
|
@ -55,7 +55,7 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte
|
|||
clusterName = ClusterName.readClusterName(in);
|
||||
nodes = new DiscoveryNode[in.readVInt()];
|
||||
for (int i=0; i<nodes.length; i++){
|
||||
nodes[i] = DiscoveryNode.readNode(in);
|
||||
nodes[i] = new DiscoveryNode(in);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
|
|||
}
|
||||
nodes = new DiscoveryNode[in.readVInt()];
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
nodes[i] = DiscoveryNode.readNode(in);
|
||||
nodes[i] = new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
legacyVersion = in.readLong();
|
||||
allocationId = in.readOptionalString();
|
||||
allocationStatus = AllocationStatus.readFrom(in);
|
||||
|
|
|
@ -51,7 +51,7 @@ public abstract class BaseNodeResponse extends TransportResponse {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.transport.DummyTransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddress;
|
||||
import org.elasticsearch.common.transport.TransportAddressSerializers;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
@ -49,8 +48,6 @@ import static org.elasticsearch.common.transport.TransportAddressSerializers.add
|
|||
*/
|
||||
public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
|
||||
|
||||
private static final DiscoveryNode PROTOTYPE = new DiscoveryNode("prototype", DummyTransportAddress.INSTANCE, Version.CURRENT);
|
||||
|
||||
public static boolean localNode(Settings settings) {
|
||||
if (Node.NODE_LOCAL_SETTING.exists(settings)) {
|
||||
return Node.NODE_LOCAL_SETTING.get(settings);
|
||||
|
@ -95,6 +92,22 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
|
|||
private final Version version;
|
||||
private final Set<Role> roles;
|
||||
|
||||
public DiscoveryNode(StreamInput in) throws IOException {
|
||||
this.nodeName = in.readString().intern();
|
||||
this.nodeId = in.readString().intern();
|
||||
this.hostName = in.readString().intern();
|
||||
this.hostAddress = in.readString().intern();
|
||||
this.address = TransportAddressSerializers.addressFromStream(in);
|
||||
int size = in.readVInt();
|
||||
ImmutableOpenMap.Builder<String, String> attributesBuilder = ImmutableOpenMap.builder(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
attributesBuilder.put(in.readString().intern(), in.readString().intern());
|
||||
}
|
||||
this.attributes = attributesBuilder.build();
|
||||
this.version = Version.readVersion(in);
|
||||
this.roles = resolveRoles(this.attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link DiscoveryNode}
|
||||
* <p>
|
||||
|
@ -335,25 +348,9 @@ public class DiscoveryNode implements Writeable<DiscoveryNode>, ToXContent {
|
|||
return this.version;
|
||||
}
|
||||
|
||||
public static DiscoveryNode readNode(StreamInput in) throws IOException {
|
||||
return PROTOTYPE.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscoveryNode readFrom(StreamInput in) throws IOException {
|
||||
String nodeName = in.readString().intern();
|
||||
String nodeId = in.readString().intern();
|
||||
String hostName = in.readString().intern();
|
||||
String hostAddress = in.readString().intern();
|
||||
TransportAddress address = TransportAddressSerializers.addressFromStream(in);
|
||||
int size = in.readVInt();
|
||||
ImmutableOpenMap.Builder<String, String> attributesBuilder = ImmutableOpenMap.builder(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
attributesBuilder.put(in.readString().intern(), in.readString().intern());
|
||||
}
|
||||
ImmutableOpenMap<String, String> attributes = attributesBuilder.build();
|
||||
Version version = Version.readVersion(in);
|
||||
return new DiscoveryNode(nodeName, nodeId, hostName, hostAddress, address, attributes, version);
|
||||
return new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -599,7 +599,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
}
|
||||
}
|
||||
|
||||
public DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
|
||||
private DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws IOException {
|
||||
Builder builder = new Builder();
|
||||
if (in.readBoolean()) {
|
||||
builder.masterNodeId(in.readString());
|
||||
|
@ -609,7 +609,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
}
|
||||
int size = in.readVInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
DiscoveryNode node = DiscoveryNode.readNode(in);
|
||||
DiscoveryNode node = new DiscoveryNode(in);
|
||||
if (localNode != null && node.id().equals(localNode.id())) {
|
||||
// reuse the same instance of our address and local node id for faster equality
|
||||
node = localNode;
|
||||
|
|
|
@ -125,7 +125,7 @@ public class AllocationExplanation implements Streamable {
|
|||
for (int j = 0; j < size2; j++) {
|
||||
DiscoveryNode node = null;
|
||||
if (in.readBoolean()) {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
}
|
||||
ne.add(new NodeExplanation(node, in.readString()));
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ public class NodesFaultDetection extends FaultDetection {
|
|||
super.readFrom(in);
|
||||
nodeId = in.readString();
|
||||
clusterName = ClusterName.readClusterName(in);
|
||||
masterNode = DiscoveryNode.readNode(in);
|
||||
masterNode = new DiscoveryNode(in);
|
||||
clusterStateVersion = in.readLong();
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ public class MembershipAction extends AbstractComponent {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -204,7 +204,7 @@ public class MembershipAction extends AbstractComponent {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.Map;
|
|||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.elasticsearch.cluster.ClusterName.readClusterName;
|
||||
import static org.elasticsearch.cluster.node.DiscoveryNode.readNode;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -120,9 +119,9 @@ public interface ZenPing extends LifecycleComponent<ZenPing> {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
clusterName = readClusterName(in);
|
||||
node = readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
if (in.readBoolean()) {
|
||||
master = readNode(in);
|
||||
master = new DiscoveryNode(in);
|
||||
}
|
||||
this.hasJoinedOnce = in.readBoolean();
|
||||
this.id = in.readLong();
|
||||
|
|
|
@ -212,7 +212,7 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
|
|||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
fromNode = DiscoveryNode.readNode(in);
|
||||
fromNode = new DiscoveryNode(in);
|
||||
indices = new IndexMetaData[in.readVInt()];
|
||||
for (int i = 0; i < indices.length; i++) {
|
||||
indices[i] = IndexMetaData.Builder.readFrom(in);
|
||||
|
|
|
@ -270,9 +270,9 @@ public class RecoveryState implements ToXContent, Streamable {
|
|||
stage = Stage.fromId(in.readByte());
|
||||
shardId = ShardId.readShardId(in);
|
||||
restoreSource = RestoreSource.readOptionalRestoreSource(in);
|
||||
targetNode = DiscoveryNode.readNode(in);
|
||||
targetNode = new DiscoveryNode(in);
|
||||
if (in.readBoolean()) {
|
||||
sourceNode = DiscoveryNode.readNode(in);
|
||||
sourceNode = new DiscoveryNode(in);
|
||||
}
|
||||
index.readFrom(in);
|
||||
translog.readFrom(in);
|
||||
|
|
|
@ -92,8 +92,8 @@ public class StartRecoveryRequest extends TransportRequest {
|
|||
super.readFrom(in);
|
||||
recoveryId = in.readLong();
|
||||
shardId = ShardId.readShardId(in);
|
||||
sourceNode = DiscoveryNode.readNode(in);
|
||||
targetNode = DiscoveryNode.readNode(in);
|
||||
sourceNode = new DiscoveryNode(in);
|
||||
targetNode = new DiscoveryNode(in);
|
||||
metadataSnapshot = new Store.MetadataSnapshot(in);
|
||||
recoveryType = RecoveryState.Type.fromId(in.readByte());
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe
|
|||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
shardActive = in.readBoolean();
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ConnectTransportException extends ActionTransportException {
|
|||
public ConnectTransportException(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
if (in.readBoolean()) {
|
||||
node = DiscoveryNode.readNode(in);
|
||||
node = new DiscoveryNode(in);
|
||||
} else {
|
||||
node = null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue