Fix compile, NetworkUtils get hostname and address methods changed

Original commit: elastic/x-pack-elasticsearch@64a94930dd
This commit is contained in:
Ryan Ernst 2015-08-18 00:13:23 -07:00
parent 4b0888926d
commit dbaf3166ef
6 changed files with 13 additions and 13 deletions

View File

@ -239,8 +239,8 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
*/ */
public void start(boolean master) { public void start(boolean master) {
if (state.compareAndSet(State.INITIALIZED, State.STARTING)) { if (state.compareAndSet(State.INITIALIZED, State.STARTING)) {
this.nodeHostName = NetworkUtils.getLocalHostName("n/a"); this.nodeHostName = NetworkUtils.getLocalHost().getHostName();
this.nodeHostAddress = NetworkUtils.getLocalHostAddress("n/a"); this.nodeHostAddress = NetworkUtils.getLocalHost().getHostAddress();
if (client == null) { if (client == null) {
initializeClient(); initializeClient();
@ -559,7 +559,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
// the call was originated locally on this node // the call was originated locally on this node
builder.field(Field.ORIGIN_TYPE, "local_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; return builder;
} }

View File

@ -265,7 +265,7 @@ public class LoggingAuditTrail implements AuditTrail {
// the call was originated locally on this node // the call was originated locally on this node
return builder.append("origin_type=[local_node], origin_address=[") return builder.append("origin_type=[local_node], origin_address=[")
.append(NetworkUtils.getLocalHostAddress("_local")) .append(NetworkUtils.getLocalHost().getHostAddress())
.append("]") .append("]")
.toString(); .toString();
} }
@ -273,13 +273,13 @@ public class LoggingAuditTrail implements AuditTrail {
static String resolvePrefix(Settings settings) { static String resolvePrefix(Settings settings) {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
if (settings.getAsBoolean("shield.audit.logfile.prefix.emit_node_host_address", false)) { 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) { if (address != null) {
builder.append("[").append(address).append("] "); builder.append("[").append(address).append("] ");
} }
} }
if (settings.getAsBoolean("shield.audit.logfile.prefix.emit_node_host_name", false)) { 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) { if (hostName != null) {
builder.append("[").append(hostName).append("] "); builder.append("[").append(hostName).append("] ");
} }

View File

@ -587,8 +587,8 @@ public class IndexAuditTrailTests extends ShieldIntegTestCase {
DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) hit.field("@timestamp").getValue()); DateTime dateTime = ISODateTimeFormat.dateTimeParser().withZoneUTC().parseDateTime((String) hit.field("@timestamp").getValue());
assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true)); assertThat(dateTime.isBefore(DateTime.now(DateTimeZone.UTC)), is(true));
assertThat(NetworkUtils.getLocalHostName("n/a"), equalTo(hit.field("node_host_name").getValue())); assertThat(NetworkUtils.getLocalHost().getHostName(), equalTo(hit.field("node_host_name").getValue()));
assertThat(NetworkUtils.getLocalHostAddress("n/a"), equalTo(hit.field("node_host_address").getValue())); assertThat(NetworkUtils.getLocalHost().getHostAddress(), equalTo(hit.field("node_host_address").getValue()));
assertEquals(layer, hit.field("layer").getValue()); assertEquals(layer, hit.field("layer").getValue());
assertEquals(type, hit.field("event_type").getValue()); assertEquals(type, hit.field("event_type").getValue());

View File

@ -490,7 +490,7 @@ public class LoggingAuditTrailTests extends ESTestCase {
} }
TransportAddress address = message.remoteAddress(); TransportAddress address = message.remoteAddress();
if (address == null) { 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; return;
} }

View File

@ -45,12 +45,12 @@ public class IPFilterTests extends ESTestCase {
nodeSettingsService = mock(NodeSettingsService.class); nodeSettingsService = mock(NodeSettingsService.class);
httpTransport = mock(HttpServerTransport.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.boundAddress()).thenReturn(new BoundTransportAddress(httpAddress, httpAddress));
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED); when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
transport = mock(Transport.class); 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.boundAddress()).thenReturn(new BoundTransportAddress(address, address));
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED); when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
} }

View File

@ -46,7 +46,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase {
boolean isHttpEnabled = randomBoolean(); boolean isHttpEnabled = randomBoolean();
Transport transport = mock(Transport.class); 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.boundAddress()).thenReturn(new BoundTransportAddress(address, address));
when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED); when(transport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
@ -55,7 +55,7 @@ public class IPFilterNettyUpstreamHandlerTests extends ESTestCase {
if (isHttpEnabled) { if (isHttpEnabled) {
HttpServerTransport httpTransport = mock(HttpServerTransport.class); 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.boundAddress()).thenReturn(new BoundTransportAddress(httpAddress, httpAddress));
when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED); when(httpTransport.lifecycleState()).thenReturn(Lifecycle.State.STARTED);
ipFilter.setHttpServerTransport(httpTransport); ipFilter.setHttpServerTransport(httpTransport);