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