From 7fefd764add75386ef83c4da842e6aa68ca57627 Mon Sep 17 00:00:00 2001 From: Andrey Kurilov Date: Mon, 16 Jan 2017 01:05:04 +0300 Subject: [PATCH] v3.0.5 --- .../impl/base/BasicStorageMockClient.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/storage/mock/src/main/java/com/emc/mongoose/storage/mock/impl/base/BasicStorageMockClient.java b/storage/mock/src/main/java/com/emc/mongoose/storage/mock/impl/base/BasicStorageMockClient.java index 7fbfbfe1e3..8f9d0986a8 100644 --- a/storage/mock/src/main/java/com/emc/mongoose/storage/mock/impl/base/BasicStorageMockClient.java +++ b/storage/mock/src/main/java/com/emc/mongoose/storage/mock/impl/base/BasicStorageMockClient.java @@ -13,6 +13,8 @@ import com.emc.mongoose.ui.log.LogUtil; import com.emc.mongoose.ui.log.Markers; import com.emc.mongoose.ui.log.NamingThreadFactory; +import static com.emc.mongoose.storage.mock.impl.http.Nagaina.SVC_NAME; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -42,8 +44,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; - -import static com.emc.mongoose.storage.mock.impl.http.Nagaina.SVC_NAME; import static java.rmi.registry.Registry.REGISTRY_PORT; /** @@ -177,22 +177,19 @@ public void serviceRemoved(final ServiceEvent event) { @SuppressWarnings("unchecked") @Override public void serviceResolved(final ServiceEvent event) { - final Consumer c = new Consumer() { - @Override - public final void accept(final String hostAddress) { - try { - final URI rmiUrl = new URI( - "rmi", null, hostAddress, REGISTRY_PORT, "/" + SVC_NAME, null, null - ); - final StorageMockServer mock = (StorageMockServer) Naming.lookup( - rmiUrl.toString() - ); - remoteNodeMap.putIfAbsent(hostAddress, mock); - } catch(final NotBoundException | MalformedURLException | RemoteException e) { - LogUtil.exception(LOG, Level.ERROR, e, "Failed to lookup node"); - } catch(final URISyntaxException e) { - LOG.debug(Markers.ERR, "RMI URL syntax error {}", e); - } + final Consumer c = hostAddress -> { + try { + final URI rmiUrl = new URI( + "rmi", null, hostAddress, REGISTRY_PORT, "/" + SVC_NAME, null, null + ); + final StorageMockServer mock = (StorageMockServer) Naming.lookup( + rmiUrl.toString() + ); + remoteNodeMap.putIfAbsent(hostAddress, mock); + } catch(final NotBoundException | MalformedURLException | RemoteException e) { + LogUtil.exception(LOG, Level.ERROR, e, "Failed to lookup node"); + } catch(final URISyntaxException e) { + LOG.debug(Markers.ERR, "RMI URL syntax error {}", e); } }; handleServiceEvent(event, c, "Node added");