Fix compile, NetworkUtils get hostname and address methods changed
Original commit: elastic/x-pack-elasticsearch@64a94930dd
This commit is contained in:
parent
4b0888926d
commit
dbaf3166ef
|
@ -239,8 +239,8 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
|
|||
*/
|
||||
public void start(boolean master) {
|
||||
if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
|
||||
this.nodeHostName = NetworkUtils.getLocalHostName("n/a");
|
||||
this.nodeHostAddress = NetworkUtils.getLocalHostAddress("n/a");
|
||||
this.nodeHostName = NetworkUtils.getLocalHost().getHostName();
|
||||
this.nodeHostAddress = NetworkUtils.getLocalHost().getHostAddress();
|
||||
|
||||
if (client == null) {
|
||||
initializeClient();
|
||||
|
@ -559,7 +559,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
|
|||
|
||||
// the call was originated locally on this node
|
||||
builder.field(Field.ORIGIN_TYPE, "local_node");
|
||||
builder.field(Field.ORIGIN_ADDRESS, NetworkUtils.getLocalHostAddress("_local"));
|
||||
builder.field(Field.ORIGIN_ADDRESS, NetworkUtils.getLocalHost().getHostAddress());
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ public class LoggingAuditTrail implements AuditTrail {
|
|||
|
||||
// the call was originated locally on this node
|
||||
return builder.append("origin_type=[local_node], origin_address=[")
|
||||
.append(NetworkUtils.getLocalHostAddress("_local"))
|
||||
.append(NetworkUtils.getLocalHost().getHostAddress())
|
||||
.append("]")
|
||||
.toString();
|
||||
}
|
||||
|
@ -273,13 +273,13 @@ public class LoggingAuditTrail implements AuditTrail {
|
|||
static String resolvePrefix(Settings settings) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (settings.getAsBoolean("shield.audit.logfile.prefix.emit_node_host_address", false)) {
|
||||
String address = NetworkUtils.getLocalHostAddress(null);
|
||||
String address = NetworkUtils.getLocalHost().getHostAddress();
|
||||
if (address != null) {
|
||||
builder.append("[").append(address).append("] ");
|
||||
}
|
||||
}
|
||||
if (settings.getAsBoolean("shield.audit.logfile.prefix.emit_node_host_name", false)) {
|
||||
String hostName = NetworkUtils.getLocalHostName(null);
|
||||
String hostName = NetworkUtils.getLocalHost().getHostAddress();
|
||||
if (hostName != null) {
|
||||
builder.append("[").append(hostName).append("] ");
|
||||
}
|
||||
|
|
|
@ -587,8 +587,8 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
|
|||
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) hit.field("@timestamp").getValue());
|
||||
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
|
||||
|
||||
assertThat(NetworkUtils.getLocalHostName("n/a"), equalTo(hit.field("node_host_name").getValue()));
|
||||
assertThat(NetworkUtils.getLocalHostAddress("n/a"), equalTo(hit.field("node_host_address").getValue()));
|
||||
assertThat(NetworkUtils.getLocalHost().getHostName(), equalTo(hit.field("node_host_name").getValue()));
|
||||
assertThat(NetworkUtils.getLocalHost().getHostAddress(), equalTo(hit.field("node_host_address").getValue()));
|
||||
|
||||
assertEquals(layer, hit.field("layer").getValue());
|
||||
assertEquals(type, hit.field("event_type").getValue());
|
||||
|
|
|
@ -490,7 +490,7 @@ public class LoggingAuditTrailTests extends ESTestCase {
|
|||
}
|
||||
TransportAddress address = message.remoteAddress();
|
||||
if (address == null) {
|
||||
assertThat(text, equalTo("origin_type=[local_node], origin_address=[" + NetworkUtils.getLocalHostAddress("_local") + "]"));
|
||||
assertThat(text, equalTo("origin_type=[local_node], origin_address=[" + NetworkUtils.getLocalHost().getHostAddress() + "]"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ public class IPFilterTests extends ESTestCase {
|
|||
nodeSettingsService = mock(NodeSettingsService.class);
|
||||
|
||||
httpTransport = mock(HttpServerTransport.class);
|
||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(NetworkUtils.getLocalAddress(), 9200);
|
||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(NetworkUtils.getLocalHost().getHostAddress(), 9200);
|
||||
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(httpAddress, httpAddress));
|
||||
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||
|
||||
transport = mock(Transport.class);
|
||||
InetSocketTransportAddress address = new InetSocketTransportAddress(NetworkUtils.getLocalAddress(), 9300);
|
||||
InetSocketTransportAddress address = new InetSocketTransportAddress(NetworkUtils.getLocalHost().getHostAddress(), 9300);
|
||||
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(address, address));
|
||||
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase {
|
|||
boolean isHttpEnabled = randomBoolean();
|
||||
|
||||
Transport transport = mock(Transport.class);
|
||||
InetSocketTransportAddress address = new InetSocketTransportAddress(NetworkUtils.getLocalAddress(), 9300);
|
||||
InetSocketTransportAddress address = new InetSocketTransportAddress(NetworkUtils.getLocalHost().getHostAddress(), 9300);
|
||||
when(transport.boundAddress()).thenReturn(new BoundTransportAddress(address, address));
|
||||
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase {
|
|||
|
||||
if (isHttpEnabled) {
|
||||
HttpServerTransport httpTransport = mock(HttpServerTransport.class);
|
||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(NetworkUtils.getLocalAddress(), 9200);
|
||||
InetSocketTransportAddress httpAddress = new InetSocketTransportAddress(NetworkUtils.getLocalHost().getHostAddress(), 9200);
|
||||
when(httpTransport.boundAddress()).thenReturn(new BoundTransportAddress(httpAddress, httpAddress));
|
||||
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
|
||||
ipFilter.setHttpServerTransport(httpTransport);
|
||||
|
|
Loading…
Reference in New Issue